Using Applescript to find QT Properties

I'm looking for the syntax for applescript to be able to read the video & audio format of a QT movie. What I need to do is find out what the codecs the movie is using so then I can use another part of the script to either recompress the movie or upload should it be in the correct format.
I'd also love to know a way of finding out what codec is used without having to open QT Player. I know I can use the spotlight index (command line mdls) for this but we have spotlight disabled in my labs.
Thanks for any tips!

is this a separate script or a Mail rule?  at any rate, all you need to so is use the test phrase 'subject contains "ordering prepare"', though how you apply that differs according to how the script is structured.

Similar Messages

  • Using AppleScript to find specific text in mail message?

    I'm new to scripting, and I'm a bit lost on this one...
    Is there any way to use AppleScript to find a file name from within the body of a mail message so it can be used later in the script?
    Specifically, I want to use AppleScript to "read" the content of a mail message and look for a paragraph that says "Filename: MyFileName" so I can set "MyFileName" as a variable. (There will always be a paragraph that begins with "Filename: " in this particular email message.)
    This will part of a larger script that uses Fetch to download "MyFileName" from our FTP server.
    Thanks in advance for any ideas - I'm struggling with this one.
    Andy Gill

    Ok, red_menace above me had a shorter and more elegant solution to the question, I'm adding this just for another example.
    To solve your problem I'd make a mail rule that looked for any messages with "Filename:" in them (along with whatever criteria you wanted, like sender, domain, etc). The mail rule would execute the Applescript. My assumption is that the "Filename:foobar" text could be anywhere in the email, not necessarily the first thing in a paragraph, so I had to parse it differently.
    The results end up in a datalist, (theFilename {} ) that you can parse later to collect all filenames found in whatever messages were processed.
    I realize this could be cleaner, hope it's not hard to follow, but I did it really fast. It works flawlessly for me, picking out the name of the file no matter where in the email it appears.
    using terms from application "Mail"
    on perform mail action with messages theSelectedMessages for rule theRule
    repeat with aCounter from 1 to count theSelectedMessages
    set theMessage to item aCounter of theSelectedMessages
    set theContent to content of theMessage
    set theWords to every word of theContent
    set theFilename to {}
    set tid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to ":"
    repeat with thisLoop in theWords
    try
    if (text item 1 of thisLoop) is "Filename" then
    set end of theFilename to (text item 2 of thisLoop)
    -- rest of your logic goes here the display is just to show it finds the filename, take it out!
    display dialog theFilename ¬
    buttons {"OK"}
    end if
    end try
    end repeat
    set AppleScript's text item delimiters to tid
    end repeat
    end perform mail action with messages
    end using terms from
    Message was edited by: stephen.bradley Typos for the win!

  • Use Applescript to find files with certain conditions

    I am using a tool to batch convert audio files in APE format to MP3. I have thousands of files located in hundreds of folders and subfolders in my hard drive so I searched for all APE/FLAC files and then dragged and dropped them in the tool for conversion. The problem is I was not able to convert all the files successfully for a variety of reasons (original APE files are corrupt, etc.), as a result I was left with a situation where some of the folders have files convernted (both APE and MP3 in that folder) whereas others don't (APE only). Instead of manually go to each folder and subfolder to find which ones need me to convert is there an Applescript I can use to quickly list the APE files that have not been converted?

    Hello
    You may try the following shell script. Please specify DIR as the root directory to start searching. It will create output list named no_mp3_list.txt on desktop.
    #!/bin/bash
    #     list every *.ape file which has no corresponding *.mp3 file in the same directory
    #     * name matching is done in case-insensitive fashion
    DIR=~/Desktop/test                # root directory to start scanning
    OUT=~/Desktop/no_mp3_list.txt    # output file
    shopt -s nocasematch
    while read -d $'\0' f
    do
        [[ -e "${f:0:${#f}-3}mp3" ]] || echo "$f" >> "$OUT"
    done < <(find "$DIR" -iname '*.ape' -print0)
    And in case, here's a simple AppleScript wrapper for the above, which lets you choose the root directory.
    set f to (choose folder with prompt "choose root folder to start searching")'s POSIX path
    if f ends with "/" then set f to f's text 1 thru -2
    do shell script "/bin/bash -s <<'EOF' -- " & f's quoted form & "
    #     list every *.ape file which has no corresponding *.mp3 file in the same directory
    #     * name matching is done in case-insensitive fashion
    DIR=\"$1\"                        # root directory to start searching
    OUT=~/Desktop/no_mp3_list.txt    # output file
    shopt -s nocasematch
    while read -d $'\\0' f
    do
        [[ -e \"${f:0:${#f}-3}mp3\" ]] || echo \"$f\" >> \"$OUT\"
    done < <(find \"$DIR\" -iname '*.ape' -print0)
    EOF"
    Hope this may help,
    H

  • Using applescript for Find and Replace All in Pages 2.0

    i saw that Pages 2.0 is scriptable
    i try to create a script for merge use to find and replace all occurence of a certain string using a script but Pages doesn't seems to respond to "Find" even using "System Events"
    how can i do to use this function with a script
    Thanx for any help
    S.B.
    ibook G3   Mac OS X (10.4.6)  

    OK, here's another example. This one gets the text as a string and uses the offset property to find "[", presuming it to be a merge delimiter. (Pages' text doesn't support "offset of").
    One failing of this scheme is that the offsets are incorrect if you have inline objects (pictures, shapes, tables, etc.). While it is probably possible to compensate for them, that's a trickier proposition.
    <PRE>-- Example merge replacements:
    property mergeText : {"[name]", "John Smith", "[address]", "1234 Anystreet"}
    on lookup(mergeWord)
    set theCount to count of mergeText
    repeat with x from 1 to theCount by 2
    if item x of mergeText = mergeWord then
    return item (x + 1) of mergeText
    end if
    end repeat
    -- If merge field is not found, delete it (replace it with the empty string)
    return ""
    end lookup
    tell application "Pages"
    repeat
    tell body text of document 1
    -- Get text as a string so that "offset of" can be used.
    set allText to it as string
    set startOffset to offset of "[" in allText
    if (startOffset = 0) then
    exit repeat
    end if
    set endOffset to offset of "]" in allText
    select (text from character startOffset to character endOffset)
    end tell
    set mergeWord to contents of selection
    tell me to lookup(mergeWord)
    set replacement to result
    set selection to replacement
    if (replacement is "") then
    -- Get rid of extra whitespace (space or return)
    -- Do it in a "try" block to handle edge cases at start or end of text.
    try
    set theSel to (get selection)
    set ch1 to character before theSel
    set ch2 to character after theSel
    if ((ch1 is " " or ch1 is return) and (ch2 is " " or ch2 is return)) then
    select character after theSel
    delete selection
    end if
    end try
    end if
    end repeat
    end tell</PRE>
    Titanium PowerBook   Mac OS X (10.4.6)  

  • Using AppleScript to find and move text within a TextEdit document.

    The goal is to do massive restructuring of data within a text edit file that requires a great deal of repetative operations using find text. The process is to use find to locate the item, exit Find at the location in which the item resides, go to the beginning of the line, select the whole line, cut, use find to relocate to the new location, exit Find at the new location, go to the beginning of the line, and paste repeating the process until all the data is restructured. The only problem is that I cannot exit Find using the "Done" button which would put the cursor at the right spot to begin the move. Searching the internet, I found:
         click button "Done" in scroll area 1
    however, that results in:
         error "System Events got an error: Can’t get scroll area 1." number -1728 from scroll area 1
    Searching the internet has not turned up any other method. Anyone that can help?

    You can use find, something like:
    find /dir -name "*.jpg" -exec mv {} dirnew/ \;
    man find for the details...

  • Use applescript to create itunes smart playlists

    hi
    is the subject possible?
    my setup uses an intricate system of smart playlists building other smart playlists. when i add a new "theme", as i call it, like "party", "chart", "sad", "happy", etc, i dont want to have to go back through and create dozens of smart playlists each time... that is a job for my friend, applescript!
    regards
    jingo_man

    I am also interested in an answer on this. I'm not an AppleScript guru but I'm learning. My goal is to create a Smart Playlist with two criteria -- one is that the tracks exist in a specific other Smart Playlist and the other is that the track's play count is less than the average play count of all tracks in the other playlist.
    I have already managed to use AppleScript to find the average play count of all tracks in a selected Smart Playlist, I just don't yet know how to use that to automatically generate a second Smart Playlist.

  • How to find the frames-per-second of a Quicktime movie using Applescript?

    Is there a way to find out the real-time "frames per second" of a Quicktime movie?
    The only Applescript movie properties in Quicktime which I have found to be useful are "duration" and "time scale". The real-time duration of the movie in seconds is found by dividing "duration" by "time scale".
    But "time scale" only sometimes relates to any real time property. In some cases it does (2500 = PAL 25 fps, 2997 = NTSC 29.97 fps) but for many other movie types I've opened (DivX, flv, mp4 etc) the "time scale" is often reported as "600" even though the Quicktime movie inspector window will report a frame rate of 25, 29.97, 15 or some other number.
    Where does the Quicktime movie inspector window extract the FPS from, and is it possible to extract that same number, or calculate the real-time FPS of a Quicktime movie using Applescript only?
    Thanks.

    Thanks for this but unfortunately it only works for some movie types. For .dv .flv and .divx movies, this script correctly calculates the FPS. But for .mpg .mp4 and .m4v it does not.
    For .mpg movies I tested, the count of frames was always 1, so clearly the FPS calculation is always wrong.
    For the .mp4 and .m4v movies I tried, the FPS was always reported as 43, regardless of whether the actual FPS was 25 or 29.97. In all cases the count of frames was incorrect.
    A bug in Quicktime?

  • Can I find the current tab in Terminal using applescript?

    Running a script from the shell by prepending
    #! /usr/bin/osascript
    as part of my .profile, can I find the "current" tab using Applescript. Most of the time, the "current" tab will not be visible, as the shell is being initialised, or re-initialised.
    I want to set the dircolors for my shell by determining the background color of the tab in which the shell is executing.

    Under the Window menu you can activate any of the palettes that you want. In your case the Field tab is under the Object palette

  • Automate finder window properties in subfolders with AppleScript?

    Automator can set window view all the way down to the subfolders. But I have to use AppleScript to set the window's position and columns' widths one at a time.
    This is the AppleScript I use:
    tell application "Finder"
    activate
    set bounds of Finder window 1 to {top, left, window width, window height}
    select Finder window 1
    set width of column id name column of list view options of Finder window 1 to 450
    set width of column id modification date column of list view options of Finder window 1 to 150
    set width of column id size column of list view options of Finder window 1 to 100
    end tell
    Is there a way to combine both Automator's Set Window View and the AppleScript above and apply it to run automatically all the way into the subfolders? I can only do the first part to set window view but I have to do hundreds of subfolders manually for the second part.
    Google and search but couldn't find a solution.
    Any help or suggestion? Thanks!

    why don't you just change the column widths for all folders in finder? hold option while adjusting the width in one window.

  • 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 &aelig; 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.

  • Setting options in "Printer" section using Applescript InDesign CS

    How can i set define supplementary options found in the "Printer" section of the InDesign dialog box in a print preset using Applescript?
    I would like my script to set duplex option with the proper binding, according to the page orientation.
    When creating print presets manually, these extra options are stored in the print preset, but I can't find how to access them thru Applescript.
    Thanks,
    Peter

    Shane,
    Thanks for your reply, but it is not yet clear to me.
    I know you can set some print properties in the Apple Print event, such as copies, collating, target printer ...but how can I adress the printer-specific options, such as duplex printing? Could you give me a sample line of code?
    And next step, how can I include this "Apple -print" setting in an InDesign Print preset using Applescript? I suppose I have to set the apple printer prefs before creating the InDesign preset. Right?
    Thanks in advance,
    Peter

  • Finding image properties?

    I'm looking for a way in applescript to get the properties of an image in a rectangle specifically its color space. I want to be able to place info about the image in a text box.
    I can get the the images
    set theimages to all graphics of page 1
    but I can't get find the code that digs deeper into the individual images/graphic
    Can anybody help?

    There are numerous ways to skin this cat using AppleScript… Here is an example that should show you what File/Image Data is available to MDLS & SIPS… You can use AppleScript's Image Events but it's pretty much SIPS in AppleScript classes… Both of these utilities will allow you to pull particular keys if you want or you can get the whole blob and parse in AppleScript… I guess you can sort the rest…
    tell application "Adobe InDesign CS5"
              tell the active document
                        set myGraphics to all graphics
                        repeat with thisGraphic in myGraphics
                                  set imgType to image type name of thisGraphic
                                  if imgType = "JPEG" then
                                            set myFile to file path of item link of thisGraphic
      -- Convert HFS path to POSIX for the shell
                                            set myFile to quoted form of POSIX path of myFile
      -- Use Spotlight metadata
                                            set mdlsData to my mdlsImage(myFile)
      display dialog (mdlsData) giving up after 3
      -- Use Scriptable Image Processing System
                                            set sipsData to my sipsImage(myFile)
      display dialog (sipsData) giving up after 3
                                  end if
                        end repeat
              end tell
    end tell
    on mdlsImage(path)
              return (do shell script "mdls " & path)
    end mdlsImage
    on sipsImage(path)
              return (do shell script "sips −-getProperty -g all " & path)
    end sipsImage

  • 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)

  • 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 text

    No longer an issue.

Maybe you are looking for

  • Need Help with Reducing PDF Size

    Hey I'm having trouble reducing my PDF file sizes. First off, they were school projects created in Adobe Illustrator that I save to PDF form.  I'm trying to email several of them to potential employers (through Gmail) but the file size limit is 25MB,

  • Some sites are not reachable (for me) sometimes, then they are again

    I have a DSL connection at home and a Netgear WLAN router connected to it. Since I changed to Leopard some sites like google/Apple/yahoo and many others are not accessible on a random base. Sometimes I just have to change from Sarari to Firefox and e

  • Change Portal E-Mail Text Notifications

    Hi, We have configurated the notification mails  following the instructions:(http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/b37e32eb5c6200e10000000a421937/frameset.htm) But this procedure is only for changing the text, and the message is a plain

  • IDOC Invoice within system

    Hi cumulative EDI intelligence, we have a scenario as follows: Incoming IDOC creates sales order. Invoice is created from order. EDI Message IDOC INVOIC01 is configured and created when saving IDOC. For this purpose, I created the bill-to-party in WE

  • Finder piles pics in a jumble when showing items as icons

    Searching my photos in Finder can be a blessing or a confusing mess. If I search using the list feature, everything is fine and dandy, just like when i use columns A problem arises when I use icons in some folders. Let's say i click on folder ABC in