Skip to content

Instantly share code, notes, and snippets.

@squio
Created July 11, 2017 06:29
Show Gist options
  • Save squio/afe62d64bb880a04123554b95609caba to your computer and use it in GitHub Desktop.
Save squio/afe62d64bb880a04123554b95609caba to your computer and use it in GitHub Desktop.
Send VCARDs one by one from OS X to legacy Nokia s40
property device : "Nokia 515"
tell application "Finder" to set myPath to selection
on sendFile(f)
-- tell application "Finder" to set fileAlias to selection as alias
set fileAlias to f as alias
set fileToSend to fileAlias
tell application "Finder" to open fileToSend using application file id "com.apple.BluetoothFileExchange"
activate application "Bluetooth File Exchange"
tell application "System Events"
tell process "Bluetooth File Exchange"
repeat until exists window 1
end repeat
select ((row 1 of table 1 of scroll area 1 of window 1) whose value of UI element 2 of UI element 1 is device)
click button "Send" of window 1
delay 5 -- experiment here; the BT File Xchange window needs to fully load
end tell
end tell
end sendFile
if (count of myPath) is greater than 1 then
set fileList to every item of myPath
repeat with f in fileList
sendFile(f)
end repeat
else
sendFile(myPath)
end if
./vcard-spli.pl < Contacts.vcf
# select all vcardNNN.vcf files in Finder
# run the Aplescript
# you will have to confirm (or cancel) every single receivec file on the phone
#!/usr/bin/perl
undef $/;
$_ = <>;
$n = 0;
for $match (split(/(?=BEGIN:VCARD)/)) {
open(O, '>vcard' . ++$n . '.vcf');
print O $match;
close(O);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment