Re: Finder's "exists" command ignores leading zero's in filename
Re: Finder's "exists" command ignores leading zero's in filename
- Subject: Re: Finder's "exists" command ignores leading zero's in filename
- From: Stan Cleveland <email@hidden>
- Date: Fri, 23 May 2014 13:03:33 -0700
On May 23, 2014, at 10:07 AM, Nigel Garvey wrote:
> ...the way the Finder compared names meant my workaround was one of the fastest.
Hi Nigel,
I noticed a 3x speedup when I adjusted your code to work with a variable, rather than a hard-coded path.
Times below are from Script Debugger's built-in timer (and were rounded after averaging several runs):
-- hard-coded (4.50 seconds)
tell application "Finder"
repeat 1000 times
tell file "Test_00001.txt" of folder "Test" of desktop to set fileExists to ((it exists) and (its name begins with "Test_00001.txt"))
end repeat
end tell
-- variable (1.50 seconds)
set filePath to "MacHD:Users:stanc:Desktop:Test:Test_00001.txt"
tell application "Finder"
set theName to name of file filePath
repeat 1000 times
set fileExists to ((file filePath exists) and (name of file filePath begins with theName))
end repeat
end tell
Rather interesting. Does this mean that AS processes variable data more efficiently than hard-coded data? It seems logical that parsing data once would be faster than parsing it 1000 times.
Stan C.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden