Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add an iPhone call log to iCal via AppleScript iOS devices
If you're like me, it is often nice to know the time spent on a call (especially if you charge your services by the minute) and even though the cheapest cell phones out there can tell you the time you were just on the phone, that data is buried deep in iPhone's records and unaccessible from the touch GUI.

I have been using a script created in ruby called calllog2ical, which you can download from this page at Google Code. The install process is a breeze and it can be called from Terminal. After using the script for about a week, I decided it would be nicer to use an AppleScript to access the shell script, and so I wrote one. Its all of one line and goes like this:
do shell script "/usr/local/bin/calllog2ical.rb -v0 iPhone\\ Call\\ Log"
In the above code, the calendar I am syncing to is iPhone Call Log.

Notes:
  • In order to get the AppleScript to work, I had to add to the script call the bin directory that contains the script, and then double escape the spaces (with two backslashes, as seen above) in the iCal calendar's name. You can find where your ruby script is installed with the which command in terminal: which calllog2ical.rb.
  • I then created a folder called Scripts in my user's Library » iTunes directory, and placed my newly- created AppleScript in that folder. Magically, when I open iTunes, a script menu appears next to the help menu bar, and when syncing my phone, I can call that script and my entire call log appears in iCal.
  • Finally, if you open the ruby script with a generic text editor like Text Wrangler, and scroll down near the bottom, you will find (at line 267) the call to make the note of the iCal event the duration of the call in seconds. Tweaking this line will give you the call in minutes:
    newEvent.setNotes("Length of call: " + call.duration.to_s + " seconds")
[robg adds: I haven't tested this one.]
    •    
  • Currently 1.63 / 5
  You rated: 3 / 5 (8 votes cast)
 
[29,824 views]  

Add an iPhone call log to iCal via AppleScript | 18 comments | Create New Account
Click here to return to the 'Add an iPhone call log to iCal via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add an iPhone call log to iCal via AppleScript
Authored by: Canerow on Aug 26, '08 08:41:03AM

I love the look of this but can't get it to work. I get a plist 'no such file or directory' message.
Anybody else?



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: Canerow on Aug 26, '08 09:11:07AM

Actually, yes it does. Terminal just gives me an output that makes me think it doesn't. I'm quite new to this command line stuff.
I would recommend this quite highly.
One problem though. When I change the seconds to minutes in the calllog2ical.rb file the output numbers stay the same, so instead of 1140 seconds call duration iCal just claims it's 1140 minutes instead.

Can anybody help me tweak or point me in the right direction?



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: jecwobble on Aug 26, '08 10:41:03AM

I think you need to change the part that reads "call.duration.to_s" also. I don't know Ruby so I don't know if ".to_s" means "to string" or "to seconds", but you should be able to get decimal minutes by dividing "call.duration.to_s" by 60.



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: jedmtnman on Aug 26, '08 10:51:15AM
I am not a Ruby expert, but I belive it should be newEvent.setNotes("Length of call: " (call.duration/60).to_s + " minutes.") I have not tested it, I just added it to the hint for reference so it is easier to find. .to_s in Ruby is a toString method.

[ Reply to This | # ]
What? No AppStore app for this?
Authored by: jscotta on Aug 26, '08 09:05:02AM

Wow, I hadn't realized that this would be an issue. And if it was, I was expecting to see an AppStore application for doing this and perhaps adding the hours automatically to some time billing application like an iPhone version of Billings.

---
Windows because I have to. OS X because I want to.



[ Reply to This | # ]
What? No AppStore app for this?
Authored by: jedmtnman on Aug 26, '08 10:46:21AM

i agree, it would be a great app. Better than another tip calculator.



[ Reply to This | # ]
What? No AppStore app for this?
Authored by: cavenewt on Aug 27, '08 03:08:22PM

For what it's worth, Missing Sync (markspace.com) has an app that syncs your call log, can export it to spreadsheet, and you can add comments etc. It's not free--$35 or $25 for a crossgrade, which I hope I qualify for since I had Missing Sync for my Treo--but it might be worth it for those of us whose fiddle time is limited.



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: kilvano on Aug 26, '08 09:35:46AM

-bash: syntax error near unexpected token `do'

I get this error. Im a newb at bashing



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: jedmtnman on Aug 26, '08 11:18:40AM
can you be more specific about where this error occurred? When you ran it from terminal, when you ran it from the script editor? Your applescript should look like this...
http://img.skitch.com/20080826-r33cppuh5bmgmfbaym6c23xnqx.jpg

[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: thetoolman on Aug 26, '08 10:09:32AM
This is a great script, and really worked well on my first backup file import. However, in my next attempt, the script choked on some numbers that had a + sign in them. This error:
./calllog2ical.rb:102:in `match': invalid regular expression; there's no previous pattern, to which '+' would define cardinality at 1: /+1850878XXXX$/ (RegexpError)
Can you put in a filter to strip that out of the pattern match? The + is added when you look up a number in Google Maps and click to call from there. They are not necessarily numbers I would want to track, but there is no way to selectively delete items from the call history. Otherwise, great work!

[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: jedmtnman on Aug 26, '08 10:53:33AM

That sounds like a better suggestion to the creator of the Ruby Script since it appears to be an exception thrown by his code. Google code has a nice bug reporting agent.
Jed



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: Supp0rtLinux on Aug 26, '08 11:48:20AM

This is great... one issue, though: for users with multiple numbers, it only seems to resolve the number to a name in my address book if they call is from or to the primary number and not a secondary number. I see a lot of entries on the calendar that say from or to and a phone number, but on my iPhone there are none from unknown numbers. Checking the first five shows that they called from their mobile number but in my address book their mobile number is listed second and either there work or home number is listed first. Any thoughts on a solution?



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: Supp0rtLinux on Aug 26, '08 11:52:56AM

I appreciated being directed to line 267 for a solution to change the output from seconds to minutes, however when you pasted in <blockquote>newEvent.setNotes("Length of call: " + call.duration.to_s + " seconds")</blockquote> you copied the original text and not the modified text. I'm sure you're going to find very few Ruby users on this site, so it would help include the modified text.
<p>
Related, before changing anything, I noticed that all the seconds were divisible by minutes. In other words, they're all 60, 120, 180, etc. Granted cell companies record in minutes, not seconds, but the iPhone stores in seconds. It would be good if it showed the actual time... ie: 1hr, 4min, 17sec. or if by default it rounded up to the nearest minute as will be shown on our cellphone bills.



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: Supp0rtLinux on Aug 26, '08 12:14:05PM
The correct code to have it show minutes instead of seconds is:
newEvent.setNotes("Length of call: " + (call.duration/60).to_s + " minutes")
Of course, this means that for 1 minute phone calls, it will say "1 minutes". So, perhaps a Ruby expert could add the logic for an if/then statement to say basically if less than or equal to 1 then "minute", else if greater than 1, then minutes. I could do this in a shell script or perl, but my Ruby skills are sub-par.

Also note that the file in /usr/local/bin is likely restricted. You will need to do something like

sudo vi /usr/local/bin/calllog2ical.rb
to be able to edit it properly.

[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: jedmtnman on Aug 26, '08 02:01:56PM

i had replied to this but it was buried in the thread. Thanks for adding the bit about the sudo. I expected most folks to edit with bbedit, etc and to "save as admin"

jed



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: zerografix on Aug 27, '08 05:51:18AM

This could be even more useful if the ruby script Push call's from a specific address book group into different calendars



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: mac.by.jake on Dec 04, '08 01:15:37PM

I can't get this installed. I'm definitely don't know how to use terminal that well. The documentation reads for the install reads:

" In order to install on your system, cd into this install directory and enter the
# following command:
#
# sudo rake install
#
# This will install the calllog2ical.rb script into you /usr/local/bin directory
# and will install a simple launchd script."

I've completed the sudo rake install and then used the apple script mentioned in this post.

I'm getting the following error: "sh: /usr/local/bin/calllog2ical.rb: No such file or directory" when I use the applescript.

Obviously I'm not installing this properly when I use the terminal command.

Also from the posted install instruction I don't know what a simple launchd script is?

Any help is greatly appreciated.



[ Reply to This | # ]
Add an iPhone call log to iCal via AppleScript
Authored by: jedmtnman on Jan 13, '09 07:36:18AM
try
  1. unning the command from the command line. if that works, its an applescript issue
  2. if it doesnt work, did you use the
     which 
    command to make sure you know where the script is installed.
  3. have you checked user permissions to make sure that you have permission to execute the script?
jed

[ Reply to This | # ]