Title: Re: Can't Copy-Paste Calendar Events? [but almost as good - long SCRIPT]
On 10/18/00 12:32 PM, I wrote:
One caveat: it won’t work with recurring events, because they can’t be scripted.
No so. I got a way to make a new event (non-recurring) for an out-of-sequence recurring event, which might be hard to do if you don’t actually want to CHANGE one of the regular recurring events, but add one or more on non-regular days. You’ll note that the date that is offered to you is a day after the very first in the sequence rather than the one you opened, but no matter, just change it to what you want. Similarly, with a set of “non-recurring”-type events, which are all the same name (you or I would consider those recurring, but Entourage doesn’t see them that way if they weren’t set up as a single recurring event) the default date offered to you is a day later than the last one, not necessarily the one you opened. (It can’t figure out which one you opened.) But just put in the date you want: the default is only there as a guide to the format that’s best to use 9and it won’t matter if it varies, either). Final word: this version (like the one I posted before) does use Akua if you have it, or alternative basic scripting if you don’t.
-------------------DUPLICATE CALENDAR EVENTS E---------------------------
global dateFormat
tell application "Microsoft Entourage"
set theName to name of window 1
set theEvents to (every event whose subject = theName)
set check to "Next"
repeat until check = "Done"
set lastEvent to last event whose subject = theName
set {theprops, theCategories, theLinks} to lastEvent's {properties, category, links}
if recurring of theprops then set recurring of theprops to false
set theStart to start time of theprops
set theEnd to end time of theprops
try
set theDate to (the clock from theStart using system form "%d") -- needs Akua Sweets!
on error
set dateFormat to my FormatDate()
set theDate to my ShortDate(theStart) -- always m/d/yy in correct order (no leading zeros, 2-digit year)
end try
set nextDay to theStart + (1 * days)
try
set nextDate to (the clock from nextDay using system form "%d")
set theTime to (the clock from theStart using system form "%t")
set theStop to (the clock from theEnd using system form "%t")
on error
set nextDate to my ShortDate(nextDay)
set theTime to my GetTime(theStart)
set theStop to my GetTime(theEnd)
end try
display dialog "Enter a date for the next " & theName & "." & return & return & "If same start and end times, click Done to finish or Next to add another date." & return & return & "To change times, click Change Time." default answer nextDate buttons {"Next", "Change Time", "Done"} default button "Done" with icon 1
set {check, nextDate} to {button returned, text returned} of result
if check is in {"Done", "Next"} then
tell me to set nextStart to date (nextDate & " " & theTime)
tell me to set nextEnd to date (nextDate & " " & theStop)
else
display dialog "Enter a start time for the next " & theName & " on " & nextDate & ":" default answer theTime buttons {"OK"} default button "OK" with icon 1
set nextTime to text returned of result
tell me to set nextStart to date (nextDate & " " & nextTime)
display dialog "Enter an end time for the next " & theName & " on " & nextDate & "." & "Click Done to finish or Next to add another date." default answer theStop buttons {"Next", "Done"} default button "Done" with icon 1
set {check, nextStop} to {button returned, text returned} of result
tell me to set nextEnd to date (nextDate & " " & nextStop)
end if
set start time of theprops to nextStart
set end time of theprops to nextEnd
set nextEvent to make new event with properties theprops
set category of nextEvent to theCategories
repeat with theLink in theLinks
link nextEvent to theLink
repeat with anEvent in theEvents
link nextEvent to anEvent
end repeat
end repeat
end repeat
close window 1 saving yes
display dialog "All done!" buttons {"OK"} default button "OK" with icon 1
end tell
to FormatDate()
get "1/2/3"
set testDate to date (result)
set theFormat to ""
repeat with i from 1 to 3 -- as in "1/2/3"
if i = the day of testDate then
get "dd"
else if (i + 2000) = the year of testDate then
get "yy"
else
get "mm"
end if
set theFormat to theFormat & the result & "/"
end repeat
return text 1 thru -2 of theFormat
end FormatDate
on ShortDate(theDate) --with thanks to Emmanuel Levy
copy theDate to d
set day of d to 1
copy d to f
set month of f to January
if dateFormat = "mm/dd/yy" then
return "" & (1 + (d - f + 1314900) div 2629800) & "/" & (day of theDate) & "/" & (text -2 thru -1 of ("" & year of theDate))
else if dateFormat = "dd/mm/yy" then
return (text -2 thru -1 of ("0" & (day of theDate))) & "/" & (text -2 thru -1 of ("0" & (1 + (d - f + 1314900) div 2629800))) & "/" & (text -2 thru -1 of ("" & year of theDate))
else if dateFormat = "yy/mm/dd" then
return "" & year of theDate & "/" & (text -2 thru -1 of ("0" & (1 + (d - f + 1314900) div 2629800))) & "/" & (text -2 thru -1 of ("0" & (day of theDate)))
else -- some wierd thing
return theDate -- leave it in long form
end if
end ShortDate
on GetTime(theDate)
set t to time string of theDate
try
if (count of words of t) > 3 then --(if in AM/PM format. or German)
set t to word 1 of t & ":" & word 2 of t & " " & word -1 of t
else -- 24-hr format
set t to word 1 of t & ":" & word 2 of t
end if
on error -- if German/Swedish-style "." time separators used or some other problem
set {ods, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"."}}
try
set t to text item 1 of t & "." & text item 2 of t
set AppleScript's text item delimiters to ods
on error
set AppleScript's text item delimiters to ods --make sure
end try --leave t as complete time string if there's any problem
end try
return t
end GetTime
---------------------------end script -------------------------
--
Paul Berkowitz
- Re: Can't Copy-Paste Calendar Events? Paul Berkowitz
- Re: Can't Copy-Paste Calendar Events? John Santora
- Re: Can't Copy-Paste Calendar Events? Christian M. M. Brady
- Re: Can't Copy-Paste Calendar Events? [but ... Paul Berkowitz
- Re: Can't Copy-Paste Calendar Events? [but ... Paul Berkowitz
- Re: Can't Copy-Paste Calendar Events? [but ... Paul Berkowitz
- Re: Can't Copy-Paste Calendar Events? [... Joshua Jabbour
- Re: Can't Copy-Paste Calendar Event... Paul Berkowitz
- Re: Can't Copy-Paste Calendar ... Joshua Jabbour
- Re: Can't Copy-Paste Calen... Paul Berkowitz
- Re: Can't Copy-Paste Calendar ... Bruce Klutchko
- Re: Can't Copy-Paste Calen... Paul Berkowitz
- Re: Can't Copy-Paste Calendar ... Bruce Klutchko
- Re: Can't Copy-Paste Calen... Paul Berkowitz
- Re: Can't Copy-Paste C... Christian M. M. Brady
- Re: Can't Copy-Paste Calendar Events? [... Allen Watson
