Title: Re: Can't Copy-Paste Calendar Events? [but almost as good - long SCRIPT]
On 10/18/00 7:46 AM, "John Santora" <[EMAIL PROTECTED]> wrote:
> It's more than annoying. My example was probably too trivial, so it didn't
> truly convey the shortcomings of this omission.
>
> Let's take a more real-world example. You have a project on a really tight
> deadline, and need to schedule 5 meetings over a 21-day period. You have 7
> people who should attend these meetings, and you want to send invitations
> out to all of them. You create the event for the first meeting, setting
> links, reminders and invitations, and then want to duplicate the event for
> the remaining 4 meetings, but they are not on any kind of recurring
> schedule. Copy-drag would be a *whole* lot easier than having to *re-create*
> the event from scratch 4 more times.
I have a solution that is almost as good. It’s better with Akua Sweets in your Scripting Additions folder of your system folder (and restart computer) and would be a shorter script here if I’d left it that way. Unfortunately the Akua server seems to be down at the moment, so going there, or via http://macsripter.net is fruitless just at the moment. So here's the longer version; sorry, everyone for the length. (The difference between the two versions is that with Akua you will get your date in the dialogs in _precisely_ the same short form as you're used to from the Date & Time Control Panel, as Entourage does. Without Akua, you get it in the same month/day/year order as you always do, but with / slashes as separators and leading zeroes as I set them (too complicated to explain here). But in the Calendar it will all come out as usual regardless. (It’s only in the script dialogs that there’s any difference.)
OPERATION:
Double-click the event you want to duplicate to open it up in the front, then run the script. (If you make any changes first, you must save.) If you're only changing the date and not the start and end times, you just type in the bit of the date that's different (the default that will show up is one day after the original, just change it to whatever you want.) If you only want that one, click "Done", and you're done. If you want more, click "Next" and repeat the process. If you want to change start or end time for any of them click "Change Time", and change the times that comes up (default is the original time).
After you click "Done", you will find all the events in place, complete with title, location, description notes, categories, and links to everything the original was linked to plus all the other events with the same title, including the new ones and older ones that you didn't open.
How's that?
-----------------------DUPLICATE 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}
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
