Exporting using Applescript
I have a Project with many albums. I would like to export those versions in each album that have a rating of 2 or more.
The script I am currently using (downloaded from Brett Goss.Jlarson) exports every image in an album:
ie
set the images to every image version as a list
I have tried such efforts as;
set the images to (get main rating equal to 2) as a list
without success
I have set the aperture filter to a rating of 2, again without success.
Should I be qualifying the export statement or putting it in an if main rating equal to 2
Thanks
LongJohn
I have exactly the same question. I have been experimenting with AS. I found some code that almost works, but it won't select the PDF button. The sheet with the buttons is obviously not a radio button group, and I can't work out what it is.
tell application "Finder"
set draggeditems to (choose file)
repeat with thisFile in draggeditems as list
tell application "Finder" to reveal item thisFile
set thisFile to thisFile as alias
tell application "Keynote" to open thisFile
tell application "System Events"
tell application process "Keynote"
set frontmost to true
if menu item "Hide Inspector" of menu 1 of menu bar item "View" of menu bar 1 exists then
keystroke "i" using {command down, option down}
end if
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1
repeat until sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
click button "PDF" of radio group 1
click checkbox "Include slide numbers"
click checkbox "Include date"
click checkbox "Print each stage of builds"
click button "Next…"
end tell
repeat until button "Export" of sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
click button "Export"
end tell
delay 3
keystroke "w" using command down
end tell
end tell
end repeat
end tell
Similar Messages
-
Outlook for Mac Export using AppleScript
Hello,
Is it possible to write an AppleScript that will perform the export function in Outlook for Mac? I'm looking for a script I could add to Task Scheduler and automate an export every day.
Thanksgmcg012 wrote:
bringing them in to my inbox in chinese
This may indicate an encoding mismatch, utf-8 being read as if it were utf-16, probably a glitch with exchange for that account. -
Quicktime export using applescript/folder actions
I have about 500Gig of encoded H264 footage.
I want to be able to "bulk" change video properties on all of the video so that when I view it in front row it isn't letter boxed.
I can do this manually, save as a .MOV and all is fine.
anyone tried something like this as an applescript?
I have scripted eyetv quite a bit so I`m quite familiar with applescript, just being lazy I suppose!
any help greatly received !
* looking in the quicktime applescript library *
SteveThe nature of your question implies that you're unfamiliar with Folder Actions...
I'd like to skip them or write the AppleScript in a way that handles this.
By their very nature, Folder Actions are passed a list of newly-added files. Your Folder Action script should look something like:
on adding folder items to my_folder after receiving the_files
-- your code goes here
end adding folder items to
where, in this case, the_files is a list of the newly-added files. It won't include pre-existing files, so all you need to do is iterate through the_files and you're set. Something like:
on adding folder items to my_folder after receiving the_files
tell application "iPhoto"
repeat with each_photo in the_files
try
import each_photo to album "Europe 2012"
end try
end repeat
end tell
end adding folder items to
The only caveat here that I can think of is the fact it's a DropBox folder, so there might be some odd latency in the files appearing in the directory, but I don't use Dropbox to know.
Note that in the above I import each photo independently, via a repeat loop. This might not be necessary, and you might be able to pass the entire the_files variable to the import command to have all the images imported in one go - I haven't tried that, though. -
Need help using applescript to export a playlist
I'm trying to use applescript to get iTunes to export the current playlist as XML. I know this can be done via the File ->Export menu but I'd like to script this.
Hi William,
Sorry about that! Ok I just typed "xml" into the "search scripts" box in the top of the page. Take a look at the first couple of entries...or I linked the first two here:
http://www.dougscripts.com/itunes/scripts/ss.php?sp=exportselectedtracksxml
http://www.dougscripts.com/itunes/scripts/ss.php?sp=exportsmartcriteria
Let us know...
Reg -
Green frames when using AppleScript to export from QT
Not sure if this is a QuickTime issue, h.264 issue, or an AppleScript issue, but i thought I'd start here since I know the least about AppleScript and have some clues to the problem.
I'm creating an Automator workflow that requires a run AppleScript action. My plan is to use applescript to have QuickTime Pro 7.6.6 export an image sequence from a QuickTime movie in h.264, using a QuickTime settings file I've already exported. The script points to the settings file and and exports the sequence to the output folder I've specified. Im looking to export one frame per second. Running the script works well and I'm almost getting the result I want, except that each frame that is exported is entirely green.
Interestingly, when I run the exact same process manually, using the exact same settings, the export works fine, and the frames are correct. Additionally, exporting via AppleScript brings up a different status bar than when exporting manually, which leads me to believe that AppleScript is the culprit. Perhaps it's running some sort of outdated process? The AppleScript status bar comes down from the top middle of the video frame, while exporting manually, brings up a floating status bar. They look decidedly different.
Has anyone run into this problem? Can possibly shed light on it? Possible AppleScript work around? This only seems to effect h.264 videos. If I run the same AppleScript on a prores file, the images export correctly.Including the applescript in question could be helpful!
tell application "QuickTime Player 7"
export front document as image sequence using settings "Macintosh HD:Users:grato:Documents:SYNC:Sync Assets:settings:Sync_QTexport_setting.qtes" to "Macintosh HD:Users:grato:Documents:SYNC:Sync Assets:Assets:temp:Sync-"
end tell -
Exporting from Keynote 08 using applescript or automator
Hi
Does anyone have a method for triggering an export from applescript of an open keynote presentation, I have an action that takes a sequence of images (exported slides) sorts and loads into an new presentation and I would like to then export as .ppt
This allows the sad ppt user to see the slides perfectly formed (and stops them editing and stealing my ideas). However the last step of the export I have to do manually as I cant see any actions in automator or anything in the applescript dictionary.
Any ideas
thanks
JonI have exactly the same question. I have been experimenting with AS. I found some code that almost works, but it won't select the PDF button. The sheet with the buttons is obviously not a radio button group, and I can't work out what it is.
tell application "Finder"
set draggeditems to (choose file)
repeat with thisFile in draggeditems as list
tell application "Finder" to reveal item thisFile
set thisFile to thisFile as alias
tell application "Keynote" to open thisFile
tell application "System Events"
tell application process "Keynote"
set frontmost to true
if menu item "Hide Inspector" of menu 1 of menu bar item "View" of menu bar 1 exists then
keystroke "i" using {command down, option down}
end if
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1
repeat until sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
click button "PDF" of radio group 1
click checkbox "Include slide numbers"
click checkbox "Include date"
click checkbox "Print each stage of builds"
click button "Next…"
end tell
repeat until button "Export" of sheet 1 of window 1 exists
end repeat
tell sheet 1 of window 1
click button "Export"
end tell
delay 3
keystroke "w" using command down
end tell
end tell
end repeat
end tell -
How to find and replace using AppleScript for TextWrangler?
I ran into a problem after exporting my book into EPUB from Indesign CS4. In this book the Latin diphthong æ is used. Unfortuately it didn't translate very well into the EPUB or corresponding XHTML files. Is there a way to do a batch change using AppleScript to change these symbols √¶ into æ which is the code for the diphthong? If so, how?
I also have an issue with the symbol †, in some of the documents it appears as this ‚Ć. Can I do a batch change for that as well? If so, how?
I'm new to using AppleScript so I appreciate all of the help. Thank you so much!!Hello
Here's some observations -
æ = U+00E6
= <c3 a6> (UTF-8)
= <c3 a6> (MacRoman) = æ
† = U+2020
= <e2 80 a0> (UTF-8)
= <e2 80 a0> (MacRoman) = †
which likely mean that your source data is text in UTF-8 but destination (or viewer or intermediate converter) is interpreting the data as text in MacRoman.
Make sure you properly declare the encoding of XHTML or EPUB document as UTF-8.
Good luck,
H -
How I generate index markers using Applescript and tagged text!
One of the challenges I've faced in automating the book making process using Applescript with inDesign is that there don't seem to be any AS commands for making new index markers (anyone please correct me I if I'm wrong about this).
I've tried various js scripts which do an OK job, but they don't make the actual native markers. This means you have to wait until the book (consistiing of multiple ID files) is complete (so that all the page numbers have been established) to generate the index.
Recently, I read a tweet from someone with a link to a technique which uses tagged text and find and replace with GREP to edit the tags, inserting the tagged text index tags in the text file and then re-placing the text file in the ID page. In itself, this works great. But I'm dealing with literally thousands of separate text frames, none of them connected in a story.
The books typically consist of around 1200 pages with almost that many people, each of whose names I need to index with "Lastname, Firstname" references. And those particular strings don't (can't) appear anywhere on the pages. There will also be about 50 ID files all combined into one book. So it is imperative that I have ID generate the native index markers. To help keep things straight and efficient, I'm creating separate small text frames to hold the lastname, firstname strings. I created an object style for these frames which sets the attributes to "nonprinting", and I place the frames in the margin.
Then I realized that I don't actually have to have ID export the tagged text files for each. I exported one prototype and copied its tags to properties in my script, and then I concatenate them with the respective list item values I import from the database.
At the proper point in the page building script, I tell "textwrangleer" to make a new document, set its contents to the index string for the current record, save it to disk, overwriting the previous one, and then tell ID to "place" it in the index text frame, which generates the ID index mark.
I actually got an AS error when I first tried this: "file doesn't exist" or some such. Then I realized that the "place" command was happening too soon, so I inserted a .5 sec delay in the script, and it worked.
This is actually my first major script for actual work, and I'm so excited about it! I promises to cut production time down to about a thenth of what it was.
I still have to add some logic to branch between handlers with slightly different parameters for five different page formats, but the same page building handler will work on all of them.A note on this:
Daniel Swanson wrote:
I've tried various js scripts which do an OK job, but they don't make the actual native markers. This means you have to wait until the book (consistiing of multiple ID files) is complete (so that all the page numbers have been established) to generate the index.
These scripts typically search for words and immediately write out the page numbers they are found on -- one shot indexing.
The solution is to add both the topic and its page reference to the current document's index:
if (app.activeDocument.indexes.length == 0)
app.activeDocument.indexes.add();
app.activeDocument.indexes[0].topics.add(app.selection[0].contents).pageReferences.add(app.selection[0]);
The first lines only make sure there is an index to add to (per default, a new document has none).
The last line adds a selected word to the index (it must be a plain text string, hence the use of its 'contents'), and then adds a reference to the selection in the text itself.
Adding the same word a second time will for a change (quite untypically for ID's Scripting) not result in an error but simply add another page reference to the existing one.
When doing this in a loop: remember to work backwards, because the index marker itself gets inserted into the running text, and that will throw off your text indices. -
Use Applescript to list duplicates in Mac Office Excel 2011
Hello Apple scripters!
I was thinking if it's possible to use Applescript in Excel to find duplicates using conditional formating then export it on a new list.
Compare 2 columns>highlight duplicates>add result in a new csv file together with either the whole row or column line.
Thanks!
ErnestoYou might try looking/posting here.
Microsoft Support – Office for Mac
Microsoft Support – Office for Mac (2)
https://discussions.apple.com/thread/4847068?tstart=0
Try a restart.
Put a copy of the file in the hard drive level Users/Shared folder.
Do a backup, using either Time Machine or a cloning program, to ensure files/data can be recovered. Two backups are better than one.
Try setting up another admin user account to see if the same problem continues. If Back-to-My Mac is selected in System Preferences, the Guest account will not work. The intent is to see if it is specific to one account or a system wide problem. This account can be deleted later.
Isolating an issue by using another user account
If the problem is still there, try booting into the Safe Mode using your normal account. Disconnect all peripherals except those needed for the test. Shut down the computer and then power it back up after waiting 10 seconds. Immediately after hearing the startup chime, hold down the shift key and continue to hold it until the gray Apple icon and a progress bar appear. The boot up is significantly slower than normal. This will reset some caches, forces a directory check, and disables all startup and login items, among other things. When you reboot normally, the initial reboot may be slower than normal. If the system operates normally, there may be 3rd party applications which are causing a problem. Try deleting/disabling the third party applications after a restart by using the application un-installer. For each disable/delete, you will need to restart if you don't do them all at once.
Safe Mode
Safe Mode - About -
Using Applescript (or Automator) to delete Albums
When you import folders into Aperture, it creates for every folder an Album "Images from:" whatever the folder name is. Is there a way using Applescript that I can easily delete those albums? They are essentially useless as they stand to me. I am importing a large number of folders, so I am getting those albums all over my Aperture library.
The short answer is yes you can use apple script to do that - there is virtual no documentation you will have to take a look at all the methods that aperture exports to figure out what you have to do. If you are new to applescript/automator you may want to think twice about taking that on.
Just a note regarding import - There are three ways to import into aperture:
1) the normal way - import images - this takes all the images in a folder and imports them into an existing or new project.
2) if you happen to be clicked on an existing project you can use import folders as albums (what I think you are doing).
3) if you happen to be clicked on the library level or a blue folder that same option number 2 changes into import folders as projects.
Using the combination of the three may ease the import a little with out resorting to applescript/automator unless you are familiar with using those tools that may be rough going.
RB -
Using Applescript for uploading pictures on the Internet
Hello!
I was wondering if there was a way to use Applescript with Firefox (or another browser)...?
We have many many villas on our website, each one with lots of pictures. We are constantly adding new villas to our site and amending old ones.
To add pictures we go to a page in our cms for each villa, located there is a drop down menu - image 1, image 2, 3 etc etc etc
For each one we have to manually browse for and attach the photo. As you can guess this is a time consuming process, we have asked the web designer before for this but he is so busy and we have other more important stuff for him to be working on.
As Applescript is so nifty I was wondering if anybody had an idea on how to use it for this process - i.e. have a folder full of pictures on the desktop and Applescript can add them?
I have no idea if this is possible, any ideas?
Many thanks and regards.
SimonYeah I completely understand, I just wanted to see if anybody knew if it could be done.
Obviously for security reasons I can't let anybody into our CMS, so looks like it's a bit of an impossible task.
Although it would be awesome to simply change the script slightly for each villa and let it do it all, this would be stupidly complicated as there are many menus to navigate to get to the uploading picture area.
It would be great if I could do all that manually then once on that page (or given the page url to Applescript) set Applescript running to upload all the images for me.
This is what that page looks like, if this helps?!:
http://img535.imageshack.us/img535/241/screenshot20100415at141.png
The drop down menu contains:
Villa Plan
Small Location Map
Image Gallery 1
Image Gallery 2
etc
etc
I could arrange a folder with the pictures in order (i.e. Villa Plan first, then Small location Map, then the picture for 1 etc) so no worries about the Villa Plan and location map.
I've got a feeling I'm just going to have to do it manually (I shall forever be uploading pictures), but I thought I would give it to some of you geniuses to mull over!
For whoever creates a script I'll give you a discounted stay in Paradise... there's an incentive!!
Many thanks and regards,
Simon -
New to applescript. need to create a plist file using applescript
Needed some help I need on creatinga plist file below using applescript and I can't make it happen needed some hand on this.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Username</key>
<string>${localAdminUser}</string>
<key>Password</key>
<string>${localAdminPassword}</string>
<key>AdditionalUsers</key>
<array>
<dict>
<key>Username</key>
<string>${userName}</string>
<key>Password</key>
<string>${userPassword}</string>
</dict>
</array>
</dict>
</plist>
I have tis code but it doesn't seems to work.
tell application "System Events"
-- create an empty property list dictionary item
set the parent_dictionary to make new property list item with properties {kind:record}
-- create new property list file using the empty dictionary list item as contents
set the plistfile_path to "~/Desktop/example.plist"
set this_plistfile to ¬
make new property list file with properties {contents:parent_dictionary, name:plistfile_path}
-- add new property list items of each of the supported types
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Username", value:"${localAdminUser}"}
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:list, name:"AdditionalUsers"}
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Username", value:"${localAdminUser}"}
make new property list item at end of property list items of contents of this_plistfile ¬
with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
end tell
The result of the above code will generate a plist file below
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AdditionalUsers</key>
<array/>
<key>Password</key>
<string>${localAdminPassword}</string>
<key>Username</key>
<string>${localAdminUser}</string>
</dict>
</plist>Hello
You need to create elements at correct container. Like this.
set plist_file to (path to desktop)'s POSIX path & "example.plist"
--set plist_file to "~/desktop/example.plist"
tell application "System Events"
tell (make new property list file with properties {name:plist_file})
make new property list item at end with properties {kind:string, name:"Username", value:"${localAdminUser}"}
make new property list item at end with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
tell (make new property list item at end with properties {kind:list, name:"AdditionalUsers"})
tell (make new property list item at end with properties {kind:record})
make new property list item at end with properties {kind:string, name:"Username", value:"${localAdminUser}"}
make new property list item at end with properties {kind:string, name:"Password", value:"${localAdminPassword}"}
end tell
end tell
end tell
end tell
Or you may create a record in AppleScript and set the value of plist file at once. Like this.
set plist_file to (path to desktop)'s POSIX path & "example.plist"
--set plist_file to "~/desktop/example.plist"
set dict to ¬
{|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}"} & ¬
{|AdditionalUsers|:{¬
{|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}"} ¬
--set dict to {|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}", |AdditionalUsers|:{{|Username|:"${localAdminUser}", |Password|:"${localAdminPassword}"}}}
tell application "System Events"
tell (make new property list file with properties {name:plist_file})
set value to dict
end tell
end tell
Regards,
H
Message was edited by: Hiroto (PS. Fixed second script so that it uses the original case (uppercase) in key string) -
How can I change the font size of an outgoing instant message using Applescript?
Text copied into Messages.app from a web page is often too small to read. Is there a quick way to boost the font size using Applescript?
HI,
I have spent some time looking at the Mix Message Case.scpt in Hard Drive/Library/Scripts/Messages and also Crazy Message Text.scpt in the same Scripts Folder but then the Mail one.
Both are Apple versions.
The Mix Case one is set in Messages > Preferences > Alerts
Set the top drop down to Sent Message
Enable the Applescript items and chose the Mix Case item.
It will look something like this in the current Font and size you have set.
ThEn aGaIn
Obviously you don't want all the bit to make the font change between upper an lower case but it does have the option to use it with the Sent Message and it also uses the entry in the text field as a String.
The Mail Crazy Message one opens a dialogue box when run.
it has a default phase and some Upper and lower limits to the size that will be used.
the Dialogue allows you to change the phrase and also "Set Prefs" to altert the font sizes.
The result is a text palce in a new Mail items and the font and size changes to look like this:-
Picture
It will look different everytime and the Font for each character and the size of each is randomised.
Although I have tried sticking in a line to change the size to anything other then my set font in the Mixed Case one I can't get it to work.
In some cases I get an Script error in Messages (It seems to think I am setting a Font called "10")
At other times it just says it can't set it buit still does the Mixed Case bit.
My hope was to change the size and then reduce the requirement for the "intercaps" routine.
I have other emails about new posts so I will anwser them and then spend some more time on this.
9:01 PM Thursday; June 13, 2013
iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.4)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad
"Limit the Logs to the Bits above Binary Images." No, Seriously -
Adding all day events using applescript to ical
Hey all. I am new to using applescript. Thanks to some top users i have been able to get excel events file transfered into ical.
I need help with the applescript for changing these events from time duration to all day.
tried
set the start time to 00:00 and end time to 24:00 and
set all-day to true
any help would be greatly appreciated!!
thanks.I have the exact same problem. I have entered birthdays for people I know starting with the year of their birth and never ending, an all-day event. They now don't show in 2007, but there is a detached event on January 1, 2000. When I delete that event and all subsequent versions of it, the initial event now ends in 2006 or 2007, and I have to set the repeat to end Never again. I fixed all the ones from February that showed up. Now I notice that a huge amount of the other birthdays (all day events) that I have entered are doing it now, and we are talking well over 40 of them. I don't understand why it keeps creating these detached events. I also publish my calendars, if that makes any difference.
-
ICal and subscribed calendars with MobileMe using AppleScript
I am having the same problem as many of you; I have a MobileMe account which does not sync the calendars I have in iCal that are subscriptions. I found this great script online which I'll post below. I don't know anything about AppleScript so I'm just copy-pasting. I want it to work, but I'm getting the error "The variable theOldEvent is not defined." right around the line "if similar_found is true then set theOldSummary to the summary of theOldEvent" kinda near the middle. Like I said, I don't know anything about AppleScript. So my question is; how can I fix this error and/or is there some better way of using AppleScript/Automator to do this same thing? Thanks!
Script to duplicate Calendar orgCalendar into target dupCalendar
E.H. 12.9.2008
property myCopies : 0
property myUpdates : 0
property myObsoletes : 0
property orgCalendar : "Sekretariat"
property dupCalendar : "Sekretariat copy"
property dupEvents : {}
property myDeletes : {}
set myCopies to 0
set myUpdates to 0
set myObsoletes to 0
set dupEvents to {}
tell application "iCal"
-- set theCalendars to every calendar
set theCalendarNames to title of every calendar
set theOrgCalendar to a reference to calendar orgCalendar
if theCalendarNames contains dupCalendar then
set theCalendar to a reference to calendar dupCalendar
else
set theCalendar to make new calendar with properties {title:dupCalendar}
--set theCalendar to make new calendar with properties {title:dupCalendar, color:"{65535, 0, 0}"}
end if
set the eventList to uid of every event of theOrgCalendar as list
set the eventCount to the count of the eventList
repeat with theUId in eventList
tell theOrgCalendar
set theEvent to (the first event whose uid is theUId)
-- set theProperties to the properties of theEvent as record
set theDate to the start date of theEvent
set theSummary to the summary of theEvent
set theStampDate to the stamp date of theEvent
end tell
tell theCalendar
try
set theOldEvent to (the first event of theCalendar whose (start date) is theDate as date)
set similar_found to true
on error
set similar_found to false
set theEndDate to the end date of theEvent
set theAllDay to the allday event of theEvent
set theLocation to the location of theEvent
-- Funny construction to work araund the fact that location may be missing a value
try
if theLocation is equal to "" then
end if
on error
set theLocation to ""
end try
set theDescription to the description of theEvent
try
if theDescription is equal to "" then
end if
on error
set theDescription to ""
end try
if theAllDay is true then -- work around a funny bug with all day events
set theDate to (theDate as date) + 2 * hours
set theEndDate to (theEndDate as date) + 2 * hours
end if
set newEvent to make new event at end with properties {summary:theSummary, location:theLocation, start date:theDate, end date:theEndDate, allday event:theAllDay, description:theDescription}
-- make new event at end with properties theProperties
set the end of dupEvents to (the uid of newEvent)
set myCopies to (myCopies + 1)
end try
end tell
set second_necessary to false
if similar_found is true then
set theOldSummary to the summary of theOldEvent
if theSummary is not equal to theOldSummary then
--is there a different one?
try
set theOldEvent1 to (the second event of theCalendar whose (start date) is theDate as date)
set theOldSummary to the summary of theOldEvent1
if theSummary is equal to theOldSummary then
set theOldEvent to theOldEvent1
set the end of dupEvents to (the uid of theOldEvent)
else
-- cycle repeat ?
end if
on error
-- beep
try
set theEvent1 to (the second event of theOrgCalendar whose (start date) is theDate as date)
set second_necessary to true
on error
set the end of dupEvents to (the uid of theOldEvent)
end try
end try
else
set the end of dupEvents to (the uid of theOldEvent)
end if
if second_necessary is true then
set theEndDate to the end date of theEvent
tell theCalendar
set theOldEvent to make new event at end with properties {summary:theSummary, start date:theDate, end date:theEndDate}
end tell
set the end of dupEvents to (the uid of theOldEvent)
end if
set theOldStampDate to the stamp date of theOldEvent
if theStampDate is greater than theOldStampDate then
-- update the event
set summary of theOldEvent to theSummary -- capitalization may have changed
set theAllDay to the allday event of theEvent
set allday event of theOldEvent to theAllDay
set theEndDate to the end date of theEvent
if theAllDay is true then -- work around a funny bug with all day events
set theEndDate to (theEndDate as date) + 2 * hours
end if
set end date of theOldEvent to theEndDate
set theDescription to the description of theEvent
try
if theDescription is equal to "" then
end if
on error
set theDescription to ""
end try
set description of theOldEvent to theDescription
set myUpdates to myUpdates + 1
end if
end if
end repeat
end tell
-- Delete obsolete events
set myObsoletes to 0
set myDeletes to {}
tell application "iCal"
set myUIDs to uid of events of theCalendar
end tell
repeat with myUID in myUIDs
if dupEvents does not contain myUID then
set the end of myDeletes to myUID
set myObsoletes to (myObsoletes + 1)
end if
end repeat
tell application "iCal"
repeat with myDel in myDeletes
delete (every event of theCalendar whose uid is myDel)
end repeat
end tell
-- delete duplicates
set myDeletes to {}
tell application "iCal"
set myStarts to start date of events of theCalendar
set mySummaries to summary of events of theCalendar
set myUIDs to uid of events of theCalendar
set myLength to length of myUIDs
end tell
repeat with i from 1 to (myLength - 1)
set thisStart to (item i of myStarts)
set thisSumm to (item i of mySummaries)
repeat with j from (i + 1) to myLength
set thatStart to (item j of myStarts)
set thatSumm to (item j of mySummaries)
if thisSumm is equal to thatSumm and thisStart is equal to thatStart then
set the end of myDeletes to (item j of myUIDs)
exit repeat
end if
end repeat
end repeat
set n to count of myDeletes
tell application "iCal"
repeat with myDel in myDeletes
delete (every event of theCalendar whose uid is myDel)
end repeat
-- set the visible of calendar theCalendar to false
end tell
display dialog (myCopies & " records duplicated, " & myUpdates & " records updated and " & myObsoletes & " obsolete ones deleted") as textNo longer an issue.
Maybe you are looking for
-
What adaptor do I use to hook up my new MacBook Pro with an HP monitor
-
Browser bar and the bar above it disappeared, how do I get it back
I have Safari on my PC and the browser bar and the bar that has the files, edit, etc on it disappeared, how do I get it back? I was allowing my 2 year old daughter watch a show on netflix using google chrome but somehow she managed to get safari open
-
Photo does not recognize iPhoto library
Photo did not automatically import iPhoto library. Could not export iPhoto to Photo?
-
IPod cannot connect with YouTube
Every time I try to connect my iPod touch 2nd gen to YouTube it gives me an error: cannot connect to network source, too many redirections. This is not an exact quote, but it's been there for three days and youtube is not available. I have tried rese
-
MSS - CATS - Approve All to Resubmit All
Hi, One of the requirements of the client is as: "Time Approval in MSS (UWL/Approve Working Times): Currently default for approval in the Aprove Working Time is set to "Approve All" (in the drop down list). Can this default be changed to "Resubmit Al