scripts icon indicating copy to clipboard operation
scripts copied to clipboard

Perhaps some useful additions to `contacts-convert-vcf-from.sh`

Open pe1aqp opened this issue 1 year ago • 1 comments

I was interested to see which other properties appear in my .vcf files. So I included a default target in the main case-switch in your contacts-convert-vcf-from.sh script. Which duly found some empty lines.

	"")
	    # Eat empty lines
	    :
	    ;;
	
	(*)
	    # Report as-yet-unknown lines
	    echo "Unknown line: ${LINE} !" >> /dev/stderr
	    ;;

I furthermore found some "ORG" properties. In my case these these might as well have been "NOTE"s. I decided to merge these "ORG" and "NOTE" lines in a similar way as multiple telephone numbers are combined:

        (NOTE*)
          vNOTE=$( echo "${LINE}" | tr -d '|' | tr ' ' ';' | awk -F ':' '{print $2}' )
          if [ -z ${vNOTES} ]
          then
            vNOTES="${vNOTE}"
          else
            vNOTES="${vNOTES};${vNOTE}"
          fi
          ;;

        (ORG*)
          vNOTE=$( echo "${LINE}" | tr -d '|' | tr ' ' ';' | awk -F ':' '{print $2}' )
          if [ -z ${vNOTES} ]
          then
            vNOTES="${vNOTE}"
          else
            vNOTES="${vNOTES};${vNOTE}"
          fi
          ;;

(These two sections could probably be combined.)

Of course, other people might find these "ORG" entries more important and require full treatment, but that requires changes to the "DB"-file-fomat and the back-convertor.

pe1aqp avatar Aug 04 '24 22:08 pe1aqp

Oops, there were of course two more edits related to this "ORG" into "NOTE" merger that I had to do: 1/ Just like the blank lines, the "VERSION" lines should be ignored. In the main case-switch:

	(VERSION:*)
	    # Should check for v2.1, v3 or v4 !
	    :
	    ;;

2/ And the merged ORG and NOTE field should be stored. In the END / output section, use variable vNOTES instead of vNOTE:

          # NOTES
          if [ ${vNOTES} ]
          then
            echo -n "${vNOTES}"
            vNOTES=""
          else
            echo -n "-"
          fi

pe1aqp avatar Aug 05 '24 15:08 pe1aqp

Largely addressed in edit e620805.

When outputting the vNOTES variable (note plural-S), there is no need to print-out the variable vNOTE (note singular) or its leading separator.

You did not accept the reporting of as-yet-unknown lines ?

pe1aqp avatar Aug 12 '24 10:08 pe1aqp

Mostly taken-up in the "UTF-8" flavour of the vcf scripts. Some further developments can be found on: my web-site

pe1aqp avatar Aug 27 '24 22:08 pe1aqp