Re: Finder's "exists" command ignores leading zero's in
Re: Finder's "exists" command ignores leading zero's in
- Subject: Re: Finder's "exists" command ignores leading zero's in
- From: "Ken G. Brown" <email@hidden>
- Date: Thu, 22 May 2014 13:48:18 -0600
OS X 10.9.3
I have the file 00441.jpg existing on my Desktop an no other similarly named ones.
I entered this into ScriptDebugger.
--
set path_to_desktop to path to desktop folder
set my_img to path_to_desktop & “441.jpg" as string
tell application "Finder"
set file_found to exists my_img
end tell
—
Yup,
I step thru and get file_found set to true.
If I look for 41.jpg i get file_found set to false.
Ken G. Brown
On May 22, 2014, at 13:00, email@hidden wrote:
> Date: Thu, 22 May 2014 13:13:53 -0500
> From: Luther Fuller <email@hidden>
> To: Applescript Users List <email@hidden>
> Subject: Re: Finder's "exists" command ignores leading zero's in
> filename
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset="utf-8"
>
> On May 22, 2014, at 9:01 AM, Bert Groeneveld wrote:
>
>> 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've been following this thread and finally just couldn't resist trying to reproduce the results.
> I'm currently using system 10.7.5, Lion.
> I modified the original script. Here's my script ...
>
> -- the file "x000y.png" exists on the desktop
> set deskPath to (path to desktop folder) as text
> set filePath to (deskPath & "x0000y.png") as text -- this file does NOT exist
> tell application "Finder"
> set fileExists to (exists filePath) as text
> end tell
> display dialog fileExists & return & filePath
>
> try
> filePath as alias
> on error errText number errNr
> "Error = " & errNr & return & errText
> display dialog the result
> end try
>
>
> It is clear from the behavior of this script that the Finder has a serious bug.
> Experiment with line 2 by increasing the number of zeros in the file name.
>
> Strings behave this way:
> "0" ≠ "00" ≠ "000" ≠ "0000" ≠ "00000"
>
> Integers behave this way:
> 0 = 00 = 000 = 0000 = 00000
>
> The Finder is behaving as if a sub-string of zeros is equivalent to zero,
> which is erroneous integer behavior, not correct string behavior.
>
> In my script, above, the Finder incorrectly thinks that:
> "x0y" = "x00y" = "x000y" = "x0000y" = "x00000y"
>
> Perhaps I should post this message as a bug report,
> but I would first like to know if anyone can reproduce this behavior in 10.8.x and 10.9.x.
_______________________________________________
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