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: Nigel Garvey <email@hidden>
- Date: Fri, 23 May 2014 10:45:18 +0100
Bert Groeneveld wrote on Thu, 22 May 2014 16:01:45 +0200:
>set path_to_desktop to path to desktop folder
>set my_img to path_to_desktop & "2028.jpg" as string
>tell application "Finder"
> set file_found to exists my_img
>end tell
>
>When I change the name of the file on the desktop from "2028.jpg" into
>"002028.jpg" I hope to receive false as the result from above script,
but
>the result is still true. It seems that the leading zero's are ignored.
How
>can I fix that?
I seem to recall encountering this problem in Jaguar or Tiger, so it's
been around for a while.
It only occurs in situations where the Finder compares names for
_equality_, so one of the fastest ways round it (when using the Finder)
is to double-check with a test to see if the name of the match also
_begins_ with the full required name. Both tests are necessary:
tell application "Finder"
tell file "2028.txt" of desktop to set file_found to ((it exists) and (its name begins with "2028.txt"))
end tell
NG
_______________________________________________
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