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: Thomas Fischer <email@hidden>
- Date: Thu, 22 May 2014 17:36:41 +0200
Hello Yvan,
Le 22/05/2014 à 16:01, Bert Groeneveld < email@hidden> a écrit : 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?
Thanks in advance for any help, Bert.
Perfectly normal !
Your code is not checking the existence of a file but the existence of the string my_img.
I have to disagree. It looks for the file but for the Finder these files seem to be identical. I tested with
set path_to_desktop to path to desktop folder set my_img to path_to_desktop & "000234.txt" as string tell application "Finder" set myRef to a reference to file my_img set file_found to exists file my_img try open myRef end try end tell
which worked nicely with only 234.txt present and actually opened it. This is really somewhat strange: with 234a.txt and 00234a.txt present, set my_img to path_to_desktop & "0234a.txt" as string
Replace : set file_found to exists my_img by
set file_found to exists file my_img
For my own use I would code :
set path_to_desktop to path to desktop folder as text set my_img to path_to_desktop & "2028.jpg" tell application "System Events" set file_found to exists disk item my_img end tell
But this does work also on my machine.
Best Thomas
|
_______________________________________________
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