Use applescript to write iCal data to file
Posted
by Guy
on Stack Overflow
See other posts from Stack Overflow
or by Guy
Published on 2010-04-20T19:19:40Z
Indexed on
2010/04/20
19:23 UTC
Read the original article
Hit count: 191
applescript
|icalendar
I am trying to get applescript to read todays ical events and write them to a file. The code is as follows:
set out to ""
tell application "iCal"
set todaysDate to current date
set time of todaysDate to 0
set tomorrowsDate to todaysDate + (1 * days)
repeat with c in (every calendar)
set theEvents to (every event of c whose start date = todaysDate and start date < tomorrowsDate)
repeat with current_event in theEvents
set out to out & summary of current_event & "
"
end repeat
end repeat
end tell
set the_file to (((path to documents folder) as string) & "DesktopImage:ical.txt")
try
open for access the_file with write permission
set eof of the_file to 0
write out to the_file
close access the_file
on error
try
close access the_file
end try
end try
return out
The ical items are getting returned correctly and the file ical.txt is created correctly in the folder Documents/DesktopImage, but the file is blank.
Even if I substitute
write out to the_file
with
write "Test string" to the_file
it still comes up blank
any ideas?
Ty
© Stack Overflow or respective owner