AppleScript C Perl Shell Xcode Other

Convert address book to a Card file compatible with Android phones.

Post Reply
coding / perl     Views: 435Prev .. Next
Convert address book to a Card file compatible with Android phones.Posted: Friday, February 16, 2018 [04:41:14] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Bought me an Android phone and being lazy person I searched the Internet for info on how to convert my contacts to a format that would be compatible with Android phone.

Most, if not all my data stored in plain text format as it is the most useful when it comes to converting.
Data includes type of the contact phone for a given contact name, i.e. Cellphone, Work, Home etc.

So it is first converted to a multi-level hash and written to a VCard:
View Code
# .. create a hash while reading the input data (omitted) ..

foreach $name (sort keys (%byname)) {
$out .= "BEGIN:VCARD\nVERSION:3.0\n";
$out .= "FN:$name\n";
# List phones by type
foreach $phone (sort keys %{$byname{$name}}) {
$type=$byname{$name}{$phone};$phone =~ s/(\d)(\d{3})(\d{3})(\d{4})/$1\-$2\-$3\-$4/;
$out .= "TEL;type=$type:$phone\n";
} ## FOREACH PHONE END
# Place the end statement on the vCard
$out .= "END:VCARD\n";
} ## FOREACH NAME END

open(VCD,">/save_to_folder/addresses.vcf");
print VCD $out;
close(VCD);


Unless there are a few millions of records, I did not feel like installing and using Perl modules.There's no place like ~
RE: Convert address book to a Card file compatible with Android phones.Posted: Sunday, February 18, 2018 [18:28:11] - 2
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
Another idea came to mind and it works if file is saved (or copied after being saved) to a local Mac's webserver, accessible on LAN so it can be downloaded to your phone.
Add this line to your script:
View Code`cp /save_to_folder/addresses.vcf /web_folder/addresses.vcf`;


By entering LAN's address, i.e. http://YourMac.local/addresses.vcf where YourMac.local is your Mac's address on LAN - file will be automatically downloaded to your phone and contacts updated with new information.There's no place like ~
coding / perlPrev .. Next
 
Post Reply
Home - Coding: AppleScript C Perl Shell Xcode Other
Our Telegram Group