set vPath to (path to home folder as text) & "Dropbox:Backups:vCards:"
do shell script "mkdir -p " & quoted form of POSIX path of vPath
tell application "Contacts"
set {contactNames, vCards} to {name, vcard} of people
quit
end tell
set treatedNames to {}
repeat with i from 1 to (count contactNames)
set bareName to (item i of contactNames)
if bareName is in treatedNames then
set nameOfvCard to bareName & "_" & i & ".vcf"
else
set end of treatedNames to bareName
set nameOfvCard to bareName & ".vcf"
end if
set outFile to (open for access file (vPath & nameOfvCard) with write permission)
try
set eof outFile to 0
write (item i of vCards) to outFile as «class utf8»
end try
close access outFile
end repeat
1 Like