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: "koenig.yvan" <email@hidden>
- Date: Thu, 22 May 2014 17:53:28 +0200
Le 22/05/2014 à 17:36, Thomas Fischer < email@hidden> a écrit : 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 opened 00234a.txt!
I didn't wrote that the script was unable to open a file defined by a path-string.It's a wrong behaviour but at this time it is always accepted.
I just wrote that exists my_img would always return true because the string my_img exists.
My guess is that the OP wanted to use something like :
set path_to_desktop to path to desktop folder set my_img to path_to_desktop & "000234.txt" as string tell application "Finder" set file_found to exists file my_img if file_found then open my_img end tell
With that, if the file exists it would be open, if it doesn't, we would not get the awful error message :
error "Erreur dans Finder : Le gestionnaire ne peut gérer des objets de cette classe." number -10010
Yvan KOENIG (VALLAURIS, France) jeudi 22 mai 2014 17:53:12
|
_______________________________________________
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