Trouble with a script that deletes event in iCal

Used this script over the summer and it worked fine. Can't figure out the issue now, but it isn't working. Here is a few lines of the output I get and then the error I get is at the bottom. I'll post the full script at the bottom of this posting. Error # -1728??? File doesn;t exist?
Thanks,
dan
get summary of item 2 of every event of calendar "Untitled"
--> "Enviro C Lab Period 3-4"
get summary of item 2 of every event of calendar "Untitled"
--> "Enviro C Lab Period 3-4"
get description of item 2 of every event of calendar "Untitled"
--> missing value
get status of item 2 of every event of calendar "Untitled"
--> none
get start date of item 2 of every event of calendar "Untitled"
--> date "Tuesday, April 26, 2011 10:30:00 AM"
get summary of item 2 of every event of calendar "Untitled"
--> "Enviro C Lab Period 3-4"
get end date of item 2 of every event of calendar "Untitled"
--> date "Tuesday, April 26, 2011 11:55:00 AM"
get allday event of item 2 of every event of calendar "Untitled"
--> false
make new event at end of every event of calendar "Untitled" with properties {status:none, start date:date "Tuesday, April 26, 2011 10:30:00 AM", summary:"Enviro C Lab Period 3-4", end date:date "Tuesday, April 26, 2011 12:25:00 PM", allday event:false}
--> event id "AF27EFB6-3949-4977-A153-1EFE31FD8206" of calendar id "0EDA6DFD-52AD-4E7F-BC81-984CFF7D3F39"
delete item 2 of every event of calendar "Untitled"
--> error number -1728 from item 2 of every event of calendar "Untitled"
Result:
error "iCal got an error: Can’t get item 2 of every event of calendar \"Untitled\"." number -1728 from item 2 of every event of calendar "Untitled"
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into a HTML editor">
tell application "iCal"
repeat with theEvent in (events of calendar "Untitled")
set control to {}
set control to summary of theEvent
set AppleScript's text item delimiters to space
set theSummary to summary of theEvent
set textSummary to text items of theSummary
if the third item of textSummary is "Lab" then
if the fifth item of textSummary is "5-6" then
get theEvent
set theDescription to description of theEvent
set theStatus to status of theEvent
set theStartDate to (start date of theEvent) - 0.5 * hours
set theSummary to summary of theEvent
set theEndDate to end date of theEvent
set theAllDay to allday event of theEvent
set newEvent to (make new event at end of events of calendar "Untitled" with properties {status:theStatus, start date:theStartDate, summary:theSummary, end date:theEndDate, allday event:theAllDay})
set oldEvent to ""
set theEvent to oldEvent
get theEvent
delete theEvent
end if
if the fifth item of textSummary is "3-4" then
get theEvent
set theDescription to description of theEvent
set theStatus to status of theEvent
set theStartDate to start date of theEvent
set theSummary to summary of theEvent
set theEndDate to (end date of theEvent) + 0.5 * hours
set theAllDay to allday event of theEvent
set newEvent to (make new event at end of events of calendar "Untitled" with properties {status:theStatus, start date:theStartDate, summary:theSummary, end date:theEndDate, allday event:theAllDay})
delete theEvent
end if
end if
end repeat
end tell
</pre>

Hello
The posted event log indicates some inconsistent behaviour of iCal in referencing item 2 of every event. I.e., it could access it first and failed to do so after a new event is created. Scent of bug here. Or possibly inserting ugly small delay after event creation might let the script delete the newly created event...
Anyway, the 'by index' reference form of object must be used very carefully when object can be deleted or added dynamically.
Also I wish to add that it is not recommended to use an object specifier, that returns list of objects, as the base list for repeat statement, such as :
--CODE1
-- # not recommended
repeat with theEvent of (events of calendar "Untitled")
-- omitted
end repeat
--END OF CODE1
Instead, you'd better get the list first and use it, such as :
--CODE2
-- # recommended
repeat with theEvent of (get events of calendar "Untitled")
-- omitted
end repeat
--END OF CODE2
The reason is as follows.
In CODE1, the iterator is assigned as item k of events of calendar "Untitled", where k iterates from 1 to count of events of calendar "Untitled" at the time of loop entrance. The problem is that this list of events is dynamic list which may change when event is deleted or added, and consequently item k as iterator may no longer refer to the item k of the original collection of events.
In CODE2, the iterator is assigned as item k of a static list which is obtained by statement 'get events of calendar "Untitled" at the time of loop entrance. If the event object is returned in 'by ID' reference form (or any form other than that depends upon index in the container), item k as iterator is guaranteed to refer to the item k of the original collection of events whether or not collection changes.
Thus you may try something like this :
--SCRIPT
(* not tested *)
tell application "iCal"
tell calendar "Untitled"
repeat with theEvent in (get its events) -- # get the objects list
set theEvent to theEvent's contents -- # dereference each once
set AppleScript's text item delimiters to {space}
set textSummary to text items of summary of theEvent
set AppleScript's text item delimiters to {""} -- # reset astid
if item 3 of textSummary is "Lab" then
if item 5 of textSummary is "5-6" then
tell theEvent
set prop to {¬
start date:(its start date) - 0.5 * hours, ¬
end date:its end date, ¬
status:its status, ¬
summary:its summary, ¬
allday event:its allday event}
end tell
make new event at end of events with properties prop
delete theEvent
end if
if item 5 of textSummary is "3-4" then
tell theEvent
set prop to {¬
start date:its start date, ¬
end date:(its end date) + 0.5 * hours, ¬
status:its status, ¬
summary:its summary, ¬
allday event:its allday event}
end tell
make new event at end of events with properties prop
delete theEvent
end if
end if
end repeat
end tell
end tell
--END OF SCRIPT
Hope this may help,
H

Similar Messages

  • Bugs with Lion! Cannot delete events in iCal and other stuff...

    First, sorry for my English, I speak French...
    I installed Lion on my MacBook Pro, my iMac and on my girlfriend's MacBook Pro and I have the same problems on each computer! Help please!
    I try to delete an event on iCal and it always comes back!! I cannot delete it and I cannot delete an entire calendar too! It disappears and 10 seconds later, it's back!
    I also removed an icon from the Dock but when I restart the computer, it is back in the dock!
    I have also some issues with the file sharing between my Macs. Usually, I entered the username and password of the Mac and it was possible to access everything from another Mac. But now it doesn't work! I think that I must create a new user account for file sharing...
    What should I do??
    Thanks!!!

    I have the same issues with items "re-appearing" in the dock after reboot or waking from sleep. I went into recovery mode, wiped my hard drive, and cleanly reinstalled lion to no avail. I had other issues that cleared up, but my dock is full of apps I never use...so I can only conclude its a bug.

  • Script that deletes all the data in the DB

    Somebody has or know a script that delete all the data (but not the tables) of the database???? I have dummy data and know I need the tables clean of data.
    How can I delete it???????? Thank you for you help
    Javier

    You could truncate all the tables with the following commandTRUNCATE TABLE <table_name>;This will delete all the data in the table while keeping the table structure, contraints, indexes, triggers, etc. intact so they wont have to be rebuilt. All foreign keys must be disabled to use the TRUNCATE command.

  • I am having trouble with the email that is confirming my security questions, it says it has sent it to my gmail but i have checked the email account and nothing has been sent, i have waited 24 hours for it and still nothing

    i am having trouble with the email that is confirming my security questions, it says it has sent it to my gmail but i have checked the email account and nothing has been sent, i have waited 24 hours for it and still nothing.

    Hi Cara154,
    If you are having issues receiving the email verification for your security questions, you may find the following article helpful:
    When you provide a rescue email address during Apple ID creation, you will receive an email from Apple to verify that the email address provided is accurate. If you don't see an email from Apple asking you to verify your rescue email address, you may want to check your SPAM folder. If you still haven't received the email from Apple, you can sign in to My Apple ID (appleid.apple.com) to resend your rescue email address. To resend your verification email, click on Password & Security. Then, click the Resend link located in the Rescue Email Address section.
    Apple Support: Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/ht5312
    Regards,
    - Brenden

  • How to delete events on iCal that were created many years ago with a MobileMe account?

    I have never ending recurring events on iCal that I created years and years ago with my MobileMe account.  I don't have access to that email anymore, unfortunately.  Is there any way to get rid of these silly things?

    Navi,
    What Calendars are listed in your sources pane?
    Where are they located?
    Are you using iCloud?
    Backup that specific calendar using Calendar>File>Export>Export..., and save the copy to your Desktop.
    What happens if you attempt to delete that specific calendar?

  • Help with PS script that gets run when an event ID is triggered.

    Hello,
    I've had some great help from Mike Laughlin on this forum on creating a simple PS script that can email me when a particular event id is seen on a server.
    Here it is:
    $serverName = $env:COMPUTERNAME
    Send-MailMessage -to [email protected] -Subject "$serverName - Low on Virtual Memory" -body "$serverName
    - low on virtual memory" -smtpserver smtp.gb.local -from [email protected]
    What I want to add is the event id to in the email too so we can get more information, is this possible?

    Here are some suggestions:
    Here is a defined trigger for security event ID 5156.  It is good for learning because it happens frequently.
    <Triggers>
    <EventTrigger>
    <Enabled>true</Enabled>
    <Subscription>&lt;QueryList&gt;&lt;Query Id="0" Path="Security"&gt;&lt;Select Path="Security"&gt;*[System[Provider[@Name='Microsoft-Windows-Security-Auditing'] and EventID=5156]]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</Subscription>
    <ValueQueries>
    <Value name="Application">Event/EventData/Data[@Name='Application']</Value>
    <Value name="DestAddress">Event/EventData/Data[@Name='DestAddress']</Value>
    <Value name="DestPort">Event/EventData/Data[@Name='DestPort']</Value>
    <Value name="SourceAddress">Event/EventData/Data[@Name='SourceAddress']</Value>
    <Value name="SourcePort">Event/EventData/Data[@Name='SourcePort']</Value>
    <Value name="TimeCreated">Event/System/TimeCreated/@SystemTime</Value>
    </ValueQueries>
    </EventTrigger>
    </Triggers>
    The ValueQuery defines the path to the values in the event data.
    Here is how we pass the data to the command usingnamed parameters:
    <Actions Context="Author">
    <Exec>
    <Command>powershell</Command>
    <Arguments>
    -file test5156.ps1
    -Application $(Application)
    -SourceAddress $(SourceAddress)
    -SourcePort $(SourcePort)
    -DestAddress $(DestAddress)
    -DestPort $(DestPort)
    -TimeCreated $(TimeCreated)
    </Arguments>
    <WorkingDirectory>c:\test</WorkingDirectory>
    </Exec>
    </Actions>
    Notice that I do NOT use single quotes and have formatted the XML so it is easy to edit.
    The line breaks are not preserved by the XML when passed and the extra space is unimportant.
    Here is the test script that displays the passed arguments.
    Param(
    $Application,
    $SourceAddress,
    $SourcePort,
    $DestAddress,
    $DestPort,
    $TimeCreated
    '[{0:hh:mm:ss}] {1}' -f [datetime]::Now,'New Event 5156' | Out-file c:\test\testel.log -append
    $p=@{
    Application=$Application
    SourceAddress=$SourceAddress
    SourcePort=$SourcePort
    DestAddress=$DestAddress
    DestPort=$DestPort
    TimeCreated=$TimeCreated
    $parms=New-Object PsObject -Property $P
    $parms |Format-List |Out-String | Out-file c:\test\testel.log -append
    Each event ID can have very different data structures  thei si what the 5256 class o structures looks like:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    <System>
    <Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-A5BA-3E3B0328C30D}" />
    <EventID>5156</EventID>
    <Version>1</Version>
    <Level>0</Level>
    <Task>12810</Task>
    <Opcode>0</Opcode>
    <Keywords>0x8020000000000000</Keywords>
    <TimeCreated SystemTime="2015-03-18T16:51:12.152331100Z" />
    <EventRecordID>34783304</EventRecordID>
    <Correlation />
    <Execution ProcessID="4" ThreadID="3656" />
    <Channel>Security</Channel>
    <Computer>W8Test</Computer>
    <Security />
    </System>
    <EventData>
    <Data Name="ProcessID">2608</Data>
    <Data Name="Application">\device\harddiskvolume4\windows\system32\svchost.exe</Data>
    <Data Name="Direction">%%14592</Data>
    <Data Name="SourceAddress">239.255.255.250</Data>
    <Data Name="SourcePort">1900</Data>
    <Data Name="DestAddress">192.168.1.106</Data>
    <Data Name="DestPort">2232</Data>
    <Data Name="Protocol">17</Data>
    <Data Name="FilterRTID">275543</Data>
    <Data Name="LayerName">%%14610</Data>
    <Data Name="LayerRTID">44</Data>
    <Data Name="RemoteUserID">S-1-0-0</Data>
    <Data Name="RemoteMachineID">S-1-0-0</Data>
    </EventData>
    </Event>
    Note how the mappingis done from event data name and argument then to PowerSHell Parameter name.
    EVENT DATA: <Data Name="SourceAddress">239.255.255.250</Data>
    ValueQuery:   <Value name="SourceAddress">Event/EventData/Data[@Name=SourceAddress]</Value>
    TRIGGER COMMAND:
           <Arguments>
                 -file test5156.ps1
                 -SourceAddress $(SourceAddress) 
    SCRIPT PARAMS:
         Param(
             $SourceAddress,
    ¯\_(ツ)_/¯

  • Deleting event in iCal 5.0.1 not syncing with Google Calendar

    When I delete an event from iCal, it does not sync with Google Calendar.  However, when I create an event in iCal, it syncs just fine with Google Calendar. Creating and deleting events from Google Calendar syncs fine with iCal.  Has anyone else experienced this problem?

    12/13/2011 - call to google tech support
    Recent support call with Google: iCal deleting events still broken.  this is big for us.  We have users that have accounts for and/or subscribe to multiple calendars, and took a while to teach them to use iCal, so web based calendars will be foreign to them (even though I like the web based).  There is no timeline in place according to Google Tech Support.  I feel like the issue is really Apple's issue, so Google is waiting on them to fix, this type of urgency(or lack of) is right up their alley.  Oh well.
    Does anyone have any suggestions on alternate calendar apps for Mac?  Specifically for google calendars?
    "Regarding the issue about not being able to delete Google Calendar events within iCal, as mentioned it is a known issue which unfortunately we don't have a time frame to offer you.
    You can visit  http://support.google.com/calendar/bin/static.py?hl=en&page=known_issues.cs for Google Calendar known issues.
    You can submit a feature request at https://www.google.com/moderator/#16/e=ba1ca which is also located at the bottom of your Control Panel as ‘Suggest a feature.’ "

  • Need script that delete objects of certain color...

    Hello. For my Hobby I would need an Illustrator script that can delete objects of a certain color on selected layer. The color can be set in a dialog like #000000 or anything alike.
    I will need it to delete letters in text that has a certain color (different than letters around it). Letters to delete can be inside sentances or free. It doesn't matter if the text need to be outlined and ungrouped before run script, or not.
    I would apprechiate any help. Thank you.

    // CharacterColorizedIfNotMatchPrompt.jsx
    // Hint: test the script with little text.
    // The more extensive the text, the more time it takes the script.
    // greetings pixxxel schubser
    // http://forums.adobe.com/thread/1190610?tstart=0
    var aDoc  = app.activeDocument;
    var col = new CMYKColor();
    col.cyan = 0;
    col.magenta = 20;
    col.yellow = 0;
    col.black = 0;
    var aTFrame = aDoc.textFrames;
    if (aTFrame.length > 0) {
        var check = prompt ("Which character?", "a");
        check1 = check;
        check2 = check1.toUpperCase();
        for (i=0; i<aTFrame.length; i++) {
            for (j=0; j<aTFrame[i].characters.length; j++) {
                aChar = aTFrame[i].characters[j];
                if (aChar.contents != check1 && aChar.contents != check2) {
                    aChar.fillColor = col;
    alert("done")
    Try this.
    Have fun.

  • Looking for help with PowerShell script to delete folders in a Document Library

    I'd like to create a PowerShell script to delete old folders in a Document library that are over 30 days old. Has anyone created something like this?
    Orange County District Attorney

    Hello Sid:
    I am trying to do the same and Iam running the script to delete the subfolders inside a folder  but I have some errors. 
    Could you please take a look?
    _______Script________
    $web = Get-SPWeb -Identity https://myportal.mydomain.com
    $list = $web.GetList("ar_mailingactivity")
    $query =  New-Object Microsoft.SharePoint.SPQuery 
    $camlQuery = '<Where><And><Eq><FieldRef Name="ContentType" /><Value Type="Computed">Folder</Value></Eq><Leq><FieldRef Name="Created" /><Value Type="DateTime"><Today OffsetDays="-30" /></Value></Leq></And></Where>'
    $query.Query = $camlQuery
    $items = $list.GetItems($query)
    for ($intIndex = $items.Count - 1; $intIndex -gt -1; $intIndex--)
       $items.Delete($intIndex);
    ________Errors_______
    Unable to index into an object of type System.Management.Automation.PSMethod.
    At C:\Script.ps1:2 char:22
    + $list =$webGetList <<<< "ar_mailingactivity"]
    + CategoryInfo
    :InvalidOperation: (ar_mailingactivity:String) [], RuntimeException
    + FullyQualifiedErrorID
    :CannotIndex
    You cannot call a method on  a null-valued expression.
    At c:\Script.ps1:6 char:24
    + $items = $list.GetItems <<<< ($query)
    + CategoryInfo
    :InvalidOperation: (GetItems:String) [], RuntimeException
    + FullyQualifiedErrorID
    :InvokeMethodOnNull

  • Having Trouble With E-mails That Involve Animation

    This is too weird. When I receive an e-mail that has animation in it it comes through freeze framed in Mail. It does not matter if it is in my .Mac account or Verizon account. Just for the heck of it I forwarded it to myself using the Verizon account and opened it in Safari. I also did the same thing with my .mac account. I opened it on the web. Bingo, I had animation. I am also having trouble with WMV's. Why can I not get any animation in Mail? Is there something I am doing wrong? any way to correct this?

    OK, from the sound of your post, you have a limited knowledge about email. Let me see if I can help. I would guess that you have a Windows machine that you have used in the past. Your email address must be a "pop" address. That means that your internet service provider has a server where your mail is sent. This is different than a web mail address, that is accessed remotely with a web browser, such as Internet Explorer, Firefox, or Safari. You must then be using an email program, such as Outlook Express, to go get the email onto your local machine. Any email program can do this. Open up the accounts tab in Outlook Express, and write down the settings. There will be one for the incoming server, and one for the outgoing server. Now, on your Mac, you can use the email program provided, such as Mac Mail, and put the settings in there. You can now send and receive to your Mac using your supplied email address. You can use another program such as Thunderbird to do this if you want. You don't have to use Mac Mail.
    Getting your old email off of the Windows computer is a bit harder, so hopefully you don't need to do that. But if you do, I can direct you on how to do that also.

  • Help with working script that won't convert på higher version player (As2)

    HI have an issue with a file that was created some time ago to Fplayer v6 and when I now “upgrade” it to 8-9 or 10 it does not load the xml links ;/
    I have no idea why, the file(s) works fine in the old player 6
    I have a set of xml files (note: one file for each country on a map,and the possible solution should not include to put all links in the same xml file)
    the xml looks like this (example is for Denmark file called dk.xml):  [code]
    <broadcast>
    <story>
    <lead>www.alink.com</lead>
    <URL>http://www.alink.com/</URL>
    </story>
    </broadcast>
    So in the flash file I have a set of buttons the does a few actions
    one action is to call/go to a specific frame in a MC in that frame I put the Xl loading stuff for each frame (lable)
    [code]
    headlineXML = new XML();
    headlineXML.onLoad = myLoad;
    headlineXML.load("be.xml");
    function myLoad(ok) {
                                 if (ok == true) {
                                 Publish(this.firstChild);
    function Publish(HeadlineXMLNode) {
    if (HeadlineXMLNode.nodeName.toUpperCase() == "BROADCAST") {
    content = "";
    story = HeadlineXMLNode.firstChild;
    while (story != null) {
                                 if (story.nodeName.toUpperCase() == "STORY") {
                                 lead = "";
                                 URL = "";
                                 element = story.firstChild;
    while (element != null) {
    if (element.nodeName.toUpperCase() == "LEAD") {
    lead = element.firstChild.nodeValue;
    if (element.nodeName.toUpperCase() == "URL") {
                                 URL = element.firstChild.nodeValue;                                                                                                                   
    }                                                         element = element.nextSibling;
    content += "<font size='+2' color='#3366cc'><a href='"+URL+"'>"+lead+"</a></font><br>"+body+"<br><br>";
    txt.htmltext=content;
    story = story.nextSibling;
    the button (main stage)  that calles the MC frame lable with the xml that loads the load thex and a link into a dynamic txt box (called “txt”), has this code on it: [code]
    on (press) {
                                 infoon("DK");
    on (rollOver) {
                                 DK._alpha = 50;
    on (releaseOutside, rollOut, dragOut) {
                                 DK._alpha = 100;
    so as said it works fine in FP 6 (as2)  but when published to FP 8 -9 or 10 only the XML does not load at all
    What could be the issue (I know that it is old code and it is pretty poor and should be fully upgraded but my
    skills is not on that level, I managed to make the above work from some tutorials but understanding the publishing issues
    is a bit over my head J
    I would be extremely gratefull if anyone could help me out it is really frustrating especially since the file actually works fine
    in the old player ;/
    best
    OrsonB

    the two most common issues when converting from as2 vp 6 to as2 vp 6+ are:
    1.  failure to initialize some variable.  (if not explicitly initialized in vp 6, understood to be zero.  in vp+, it's undefined.)
    2.  vp6 is not case-senstive.  vp 6+ is case- sensitive.
    you have both.
    body is undefined and htmltext is not the same as htmlText.  fix those and retest.

  • Help with bash script that fails after suspend to RAM

    I have a very simple reminder script that uses an endless loop, sleep and zenity to pop up a reminder every twenty minutes:
    #!/bin/bash
    while true;
    do
    sleep 20m
    zenity --warning --title="Ergonomics Reminder" --text="Check Posture or Have a Stretch!"
    done
    However, it does not work as it should after suspending to RAM. I am thinking I need to kill the process and restart it after every suspend, using a "thaw" notice in /etc/pm but if there is an easier way to do it please let me know!

    I'm doing this for 2 reasons:
    - as a scripting exercise
    - because the local repo is a shared wordpress mess and people forget to make commits so I'd like a local backup that includes all changes that may not be in github (sadly).
    Anyhow, thanks for the input about trap, I'm definitely confused by it's use at this point but have reworked the script without it.
    #!/bin/sh
    set -e #Exit on any error.
    TIME=`date +"%m.%d.%Y@%H:%M:%S"` # Define the TIME variable as today's date and time.
    MONTH=`date +"%b"` # Define MONTH as today's month.
    FILENAME="backup-$TIME.tar.gz" # Define the filename structure.
    SRCDIR="/stuff" # Define folder to backup.
    DESDIR="/Backup/$MONTH/" # Define the backup folder location.
    LOGFILE="$DESDIR/backup-$TIME.log" # Store the output in a log.
    REMOTE=$(git ls-remote -h origin master | awk '{print $1}') # Get commit hash from head of remote master repo (github)
    LOCAL=$(git rev-parse HEAD) # Get commit hash from head of server repo (dev/test)
    if [[ $LOCAL == $REMOTE ]]; then # If the hashes match
    echo "No update required." >> $LOGFILE # Then no pull is needed
    else # If the hashes don't match then prepare to run our backup
    mkdir -p $DESDIR # Create our directory if it doesn't exist.
    echo "Backup started for "$TIME >> $LOGFILE # Make it log what it's doing.
    tar -cpzf $DESDIR/$FILENAME $SRCDIR >> $LOGFILE 2>&1 # Perform the backup.
    echo "Backup Finished for "$TIME >> $LOGFILE # Log that it's finished.
    echo "Preparing for git pull " >> $LOGFILE #Log what we're doing.
    cd /stuff >> $LOGFILE 2>&1 # Make sure we're in our repo directory
    git pull >> $LOGFILE 2>&1
    echo "Git pull completed successfully. " >> $LOGFILE
    mail -s "Backup log `date`" [email protected] < $LOGFILE # Email the output to me.
    fi

  • Error deleting events in iCal using applescript

    Hi,
    I made a little applescript to insert and remove a roster in iCal for me and my collegues.
    While the script to remove a roster works fine on my computer, others are getting an error:
    see Link: [http://i359.photobucket.com/albums/oo31/Bronco_Dappe/Allerlei/Afbeelding1.png]
    [the error contains some strange characters but in general it says:
    "can not get class ... of event id ... of calendar id ..."]
    My applescript to delete the roster is:
    on run {CalendarName, Start, Eind, Prefix}
    -- Start and Eind format:
    -- int(day) int(month) int(year) int(hour) int(minutes)
    -- ===============================
    on run
    set CalendarName to "MP"
    set Start to "15 10 2009 00 00"
    set Eind to "17 10 2009 23 59"
    set Prefix to "MP:"
    -- Version 3.0
    -- ========
    -- Changed format of Start & Eind to be compatible with Snow Leopard
    -- convert DateStart
    set wordsplit to (words in Start)
    set DateStart to (current date)
    set year of DateStart to (item 3 of wordsplit)
    set time of DateStart to 0 -- reset time
    set day of DateStart to 1 -- prevent february 31
    set month of DateStart to (item 2 of wordsplit)
    set day of DateStart to (item 1 of wordsplit)
    set DateStart to DateStart + ((item 4 of wordsplit) * hours + (item 5 of wordsplit) * minutes) -- set time
    -- convert DateEind
    set wordsplit to (words in Eind)
    set DateEind to (current date)
    set year of DateEind to (item 3 of wordsplit)
    set time of DateEind to 0
    set day of DateEind to 1
    set month of DateEind to (item 2 of wordsplit)
    set day of DateEind to (item 1 of wordsplit)
    set DateEind to DateEind + ((item 4 of wordsplit) * hours + (item 5 of wordsplit) * minutes)
    tell application "iCal"
    set TargetCalendar to first calendar whose title is CalendarName
    set list2bDeleted to {}
    set list2bDeletedSum to {}
    set listEvents to every event of TargetCalendar
    repeat with singleEvent in listEvents
    if summary of singleEvent starts with Prefix then
    set eventstart to start date of singleEvent
    if eventstart ≥ DateStart and eventstart ≤ DateEind then
    if summary of singleEvent starts with Prefix then
    copy uid of singleEvent to end of list2bDeleted
    copy summary of singleEvent to end of list2bDeletedSum
    end if
    end if
    end if
    end repeat
    repeat with eventUID in list2bDeleted
    delete (every event of TargetCalendar whose uid is eventUID)
    end repeat
    end tell
    return list2bDeletedSum
    end run
    In general the script works like this:
    1. it goes over events in a specified calendar
    2. all events to be removed are added to a delete-list by id
    3. all events in the delete-list are removed using this id
    it seems step 3 creates a problem.
    any suggestions here?
    ghislain
    Message was edited by: ghis74

    Once I got access again to an apple with Leopard I solved the problem.
    The applescript was saved in Snow Leopard.
    When opened in Leopard 'uid' in 'copy uid of singleEvent to end of list2bDeleted' was changed into '<<class>>' : 'copy <<class>> of singleEvent...'.
    Quite strange - but correcting and saving the script in Leopard solved the problem.
    Thanks for your help.
    Ghislain

  • Am I having encoding trouble with this script?

    G'day,
    I have a simple applescript, intended to get the title and url from current webpage in order to log to a text-based journaling app called Day One:
    set out_file to "/Users/home/.tmp_dayone" 
    tell application "Safari"          
         set current_tab to current tab of front window          
         set tab_name to name of current_tab as Unicode text          
         set get_url to URL of current_tab as Unicode text
    end tell 
    set text_out to "Read on the Web:  " & tab_name & " " & get_url & " " as Unicode text
    set out_file_ref to open for access POSIX file out_file with write permission
    try  
         write text_out to out_file_ref
    end try
    close access out_file_ref 
    try          
         do shell script "usr/local/bin/dayone new < " & out_file
    end try 
    delay 0.3 
    try  
         do shell script "rm " & out_file
    end try
    The script is obviously not very robust but mostly works. However...
    ...At this page http://www.ppowgallery.com/selected_work.php?artist=25 the
    name of current_tab
    returns this title:
    "P·P·O·W | The Estate of Martin Wong | Selected Text"
    Saving this to a text file and asking a shell subprocess to write a new DayOne entry from the .txt, only creates a blank entry in the journal. And I can't figure out why!
    If I use less at the terminal I can see that the ' · ' character is written as '<E1>' in the .txt. Is this what is causing the problem? If I enter
    file -I .tmp_dayone
    at the terminal the response says the file is ISO-8859-1 encoded. I don't know if any of this is relevant; I am an amateur at all of this stuff.
    Why wouldn't applescript be writing to a file as 'UTF-8" ?
    Cheers!

    Fair enough! I just added on errors in...
    I am suspicious of the ' · ' characters. Do you think they are a likely source of the problem?
    Here is the script now:
    tell application "Safari"
              set current_tab to current tab of front window
              set tab_name to name of current_tab as Unicode text
              set get_url to URL of current_tab as Unicode text
    end tell
    set text_out to "Read on the Web:
    " & tab_name & "
    " & get_url & "
    set out_file to "/Users/css/.tmp_dayone"
    set out_file_ref to open for access POSIX file out_file with write permission
    try
      write quoted form of text_out to out_file_ref
    on error
              display dialog "Couldnt write to tmp file"
    end try
    close access out_file_ref
    try
              do shell script "/usr/local/bin/dayone new < " & out_file
    on error
              display dialog "shell couldnt write to Day One"
    end try
    delay 0.3
    try
      do shell script "rm " & out_file
    on error
              display dialog "shell couldnt remove tmp file"
    end try

  • Is anyone else having trouble with reminders being automatically deleted/changed in ios7?

    Since upgrading to ios7, I've noticed the reminders app decides randomly to delete certain entries, duplicate entries and even change alert times - which is really quite disconcerting if you rely on this app as I do (or did in ios6 anyway......)
    Anyone noticed anything similar or is it just lucky old me and my seemingly intelligent and becoming wholly independent of me, iPhone?!

    Ok I have a fix for that....
    I just figured this problem out for myself with a friend]
    ==============================================================
    CLOSE SAFARI
    go to MY COMPUTER
    C:
    Documents and Settings
    Your name
    Application Data
    Apple Computer
    Safari Folder
    Delete BOOKMARKS.PLIST
    ( Now I have to warn you this WILL DELETE your bookmarks from Safari so back them up before you do this )
    NOW........
    go back and IMPORT your bookmarks
    take all your bookmarks from the "IMPORTED ON XX/XX/XXXX " folder and drop them into the BOOKMARKS MENU at the top ( not the folder just your bookmarks)
    NOW DO NOT DELETE the Imported on xx/xx/xxxx folder
    for some reason when you delete the IMPORTED ON XX/XX/XXXX folder.... It causes them to go missing under BOOKMARKS MENU
    SO as long as you dont delete the IMPORTED ON xx/xx/xxxx folder they will stay in the BOOKMARKS MENU where you can manipulate them
    ALSO... DO NOT DELETE the IMPORTED FROM INTERNET EXPLORER
    or IMPORTED FROM NETSCAPE/ MOZILLA FOLDERS
    that will also cause your bookmarks menu bookmarks to go missing too
    I guess this is a temp. fix for now
    Thanks,
    Christopher

Maybe you are looking for

  • How to use photo stream on my mac?

    I keep trying to sign in to icloud on my mac to use photo streaming.  It is turned on on my new iphone5 but everytime I enter my apple ID it says "YOu can't log in at this time, try again later"  I've tried changing my password, that didn't work.  It

  • Need to transfer from iPod to iTunes after storing iTunes on external drive

    Hello, Question: How do I safely transfer the library from the iPod tp iTunes? Background: I tried to move my iTunes to a LaCie external hard drive and now my music library is not showing up on iTunes. The complete music library is on my iPod and I w

  • Incompatible magic value

    I have developed an applet, I execute it from a PHP file and I get the following error: java.lang.ClassFormatError: Incompatible magic value 1013084704 in class file MyApplet/class      at java.lang.ClassLoader.defineClass1(Native Method)      at jav

  • Connection pool  difference in weblogic 8.x and 9.x

    Hi All, Can you please tell me why connection pool has added inside data souce from weblogic version 9.x onwards (as we know weblogic 8.x it was separte) ,recently I have faced this question from interviewer . Thanks in advance Balaji kumar Edited by

  • What about audit vault?

    Hello all, We are searching for a tool to set monitoring and set alerts for Oracle and SQLServer Databases, as per what I've found seems that Audit Vault is a nice option... however I would like to know opinions from people who already implemented th