• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Finder's "exists" command ignores leading zero's in filename
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder's "exists" command ignores leading zero's in filename


  • Subject: Re: Finder's "exists" command ignores leading zero's in filename
  • From: Luther Fuller <email@hidden>
  • Date: Thu, 22 May 2014 13:13:53 -0500

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

  • Follow-Ups:
    • Re: Finder's "exists" command ignores leading zero's in filename
      • From: Shane Stanley <email@hidden>
    • Re: Finder's "exists" command ignores leading zero's in filename
      • From: "koenig.yvan" <email@hidden>
References: 
 >Finder's "exists" command ignores leading zero's in filename (From: Bert Groeneveld <email@hidden>)

  • Prev by Date: Re: Finder's "exists" command ignores leading zero's in filename
  • Next by Date: Re: Finder's "exists" command ignores leading zero's in filename
  • Previous by thread: Re: Finder's "exists" command ignores leading zero's in filename
  • Next by thread: Re: Finder's "exists" command ignores leading zero's in filename
  • Index(es):
    • Date
    • Thread