Use System Events instead of "info for" for modification date?

I’m trying to update my AppleScripts to use System Events instead of “info for”, which I know has been deprecated. This has been fairly easy, except for this one. I use modification date and current date to determine whether a file has been completely written to the OS X file system from the SheepShaver emulator, like this:

delay 1
	repeat while (current date) - (modification date of (info for thisFile)) < 2
		delay 2
	end repeat

Can anyone suggest how I can use System Events instead of “info for” in this routine?

Thanks for any help.


set thisFile to "a:b:c:d"

delay 1
repeat
	tell application "System Events" to modification date of disk item (thisFile as text)
	if (current date) - result < 2 then exit repeat
	delay 2
end repeat

would do the trick.

Yvan KOENIG (VALLAURIS, France) lundi 10 septembre 2012 10:27:14

Actually, Yvan, that exit condition should be:

if (current date) - result ≥ 2 then exit repeat

This doesn’t use ‘current date’ at all but simply compares the file’s modification date with its previous value:


set thisFile to "a:b:c:d"

tell application "System Events"
	set thisItem to disk item (thisFile as text)
	set |then| to thisItem's modification date
	delay 1
	set now to thisItem's modification date
	repeat while (now comes after |then|)
		delay 2
		set |then| to now
		set now to thisItem's modification date
	end repeat
end tell

That does put the call to delay inside the tell block, although it looks like delay doesn’t trigger a privilege violation.

Nigel Garvey’s solution seems to work well - many thanks for it - and it isn’t something I would ever have thought of. Thank you!

delay is together with display dialog and display alert in the User Interactions Suite of Standard Additions, I guess the whole suite are exceptions from the rules about privilege violation.

Except beep :wink:

It’s one of those commands you have to be able to slip in anywhere for it to be useful at all.

Of course you’re right

Maybe this reverted test will be OK


set thisFile to "Macintosh HD:Users:yvankoenig:Desktop:convert & merge excel to csv.scpt"

delay 1
repeat
	tell application "System Events" to modification date of disk item (thisFile as text)
	if not (current date) - result < 2 then exit repeat
	delay 2
end repeat

Yvan KOENIG (VALLAURIS, France) lundi 10 septembre 2012 17:02:48