Perhaps some useful additions to `contacts-convert-vcf-from.sh`
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.
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
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 ?
Mostly taken-up in the "UTF-8" flavour of the vcf scripts. Some further developments can be found on: my web-site