Notification when iPod FINISHES syncing?

I have been reading these forums for a while and trying some stuff out, generally successful.

I have a question, I wrote a script to sync my iPod so that I can run it on schedule, as I am often in a rush for school the next morning. The only problem (a very small one) is getting it to Eject right when it is done.

I can use a “delay 10” command, but that would not work sometimes, as when my synchronize takes a bit longer than that.

So, I am asking if there is a way to detect when something is done and THEN do the next thing. I could, were I to need to, just make a very long “delay” command, but I was hoping there another way.

Thanks for any help, and here is an example of my very simple code;

tell application "iTunes"
	repeat with s in sources
		if (kind of s is iPod) then update s
	end repeat
end tell


tell application "GrowlHelperApp"
	set the allNotificationsList to ¬
		{"iTunes"}
	
	set the enabledNotificationsList to ¬
		{"iTunes"}
	
	register as application ¬
		"Growl SQI" all notifications allNotificationsList ¬
		default notifications enabledNotificationsList ¬
		icon of application "iTunes"
	
	notify with name ¬
		"iTunes" title ¬
		"iTunes" description ¬
		"iTunes has successfuly synchronized!" application name "Growl SQI"
end tell

Model: MacBook4,1
AppleScript: 2.2
Browser: Firefox 3.5.2
Operating System: Mac OS X (10.5)

Caution: I am an applescript newbie. Use this script at your own risk :smiley:

tell application "iTunes"
	activate
	tell application "System Events"
		tell process "iTunes"
			tell window 1
				tell scroll area 1
					if value of static text 1 is "iPod sync is complete." then
						set theaction to my myaction()
					end if
				end tell
			end tell
		end tell
	end tell
end tell
on myaction()
	tell application "iTunes"
		repeat with s in sources
			if (kind of s is iPod) then eject s
		end repeat
	end tell
end myaction

Thanks for the help, but I didnt get any response at all

To get a response, the ipod must have finished syncing and your selection must be the ipod (in the left side panel)

It doesnt go as far as to actually sync it. If it were already synced it would, briefly at least, still show the syncing icon

Here’s an idea, although I’m not sure if it will work.

When you update an ipod presumably the free space on the disk will be changing because you are either writing files to it or removing files from it. So you could go into a repeat loop checking the free space on the disk. When the free space stops changing then presumably the update is finished… so something like this might work.

tell application "iTunes"
	repeat with s in sources
		if (kind of s is iPod) then
			update s
			set freeSpace to free space of s
			repeat
				delay 10 -- some arbitrary value
				set currentFreeSpace to free space of s
				if currentFreeSpace is equal to freeSpace then
					exit repeat
				else
					set freeSpace to currentFreeSpace
				end if
			end repeat
		end if
	end repeat
end tell

and it selects the second freeSpace command, I will see if I can figure any of this out

I typed this line wrong…
set currentFreeSpace to freeSpace of s

Change it to this…
set currentFreeSpace to free space of s

Note: I fixed my script above to reflect this fix

Still does not seem to want to Eject right after. Thanks for the help, but I might just stick an Eject script on my iCal a half hour or so after the Sync script.