While reading, a macworld tip
Which informed the users of iCal, How they could use the url field for local file urls as well as web. ( which I did know already ;))
I thought I would write a script to make it less tedious.
Any comments or ideas welcome (well nearly any :D)
Use this script to help add a link to a local file or folder in iCal url field.
Place this script in you iCal script menu, or the Applescript menu.
When in iCal: Select the url field, for the event you want to add a link to a local file or folder.
Now go to the iTunes script menu or applscript menu,
which ever you place the script in, and selected the script. The script will prompt you to choose the typ of item for you link, File or Folder. It will then place a time stamp in the url.
(YOU MUST HAVE THE URL FIELD SELECTED FIRST).
The script will now search iCal for the event with the timestamp, once found it will replace the timestamp with the url of the item you chose.
(*Script by Mark hunte October 2007*)
(*Use this script to help add a link to a local file or folder in iCal url field.
Place this script in you iCal script menu, or the Applescript menu.
When in iCal: Select the url field, for the event you want to add a link to a local file or folder.
Now go to the iTunes script menu or applscript menu,
which ever you place the script in, and selected the script. The script will prompt you to choose the typ of item for you link, File or Folder. It will then place a time stamp in the url.
(YOU MUST HAVE THE URL FIELD SELECTED FIRST).
The script will now search iCal for the event with the timestamp, once found it will replace the timestamp with the url of the item you chose.*)
global ud, the_event, the_eventProps
tell application "iCal"
activate
(*get a time stamp code to enter in the selected url address. This will be used to search the events*)
set timestamp to "http://" & (do shell script "date +'%H%M%S'" as string)
(*choose what type of item you want to select, file of folder *)
display dialog "Get URL of ?" buttons {"Cancel", "File", "Folder"} default button 3
if the button returned of the result is "Folder" then
set mychoice to "Folder"
my myUrl(mychoice, timestamp)
else if the button returned of the result is "File" then
set mychoice to "File"
my myUrl(mychoice, timestamp)
end if
end tell
on myUrl(mychoice, timestamp)
(*set and Run the choose dialog *)
set chosen to "tell application \"ical\" to (choose " & mychoice & " without invisibles and multiple selections allowed as alias)" as string
set the_item to run script chosen
(*get the url of the file or folder *)
tell application "Finder" to set theFileURL to (URL of the_item)
tell application "System Events"
(*stamp the timestamp into the url field*)
keystroke timestamp
delay 1
(*hit escape button so the url field is set, or ical will not see the change*)
keystroke (key code 53)
tell application "iCal"
set the_event to ""
repeat with i from 1 to (count of calendars)
tell calendar i
try
(*look for the event url with the timestamp*)
set the_event to (first event whose url contains timestamp)
(*set the event url to the file/folder url*)
set url of the_event to theFileURL
(*exit, the is no need to carry on *)
if the_event is not "" then
exit repeat
end if
end try
end tell
end repeat
end tell
end tell
end myUrl