• 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: "koenig.yvan" <email@hidden>
  • Date: Thu, 22 May 2014 21:10:01 +0200


Le 22/05/2014 à 20:13, Luther Fuller <email@hidden> a écrit :

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.


Here, running 10.9.3 in French I get a correct behaviour :

tell current application
path to desktop
--> alias "SSD 500:Users:••••••••••:Desktop:"
end tell
tell application "Finder"
exists "SSD 500:Users:••••••••••:Desktop:a00000x.txt"
--> false
end tell
tell application "AppleScript Editor"
display dialog "false
SSD 500:Users:••••••••••:Desktop:a00000x.txt"
--> {button returned:"OK"}
display dialog "Error = -43
Le fichier SSD 500:Users:••••••••••:Desktop:a00000x.txt est introuvable."
--> {button returned:"OK"}

As you may see, exists … returns the correct false and filepath as alias returns the correct false.

Some features related to text are related to the language in use.
Maybe the behaviour depends of this feature.

I'm too tired to reboot in English for see.
If I have some free time tomorrow I will test in English and maybe in some other languages.

Yvan KOENIG (VALLAURIS, France) jeudi 22 mai 2014 21:09:14



 _______________________________________________
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: Luther Fuller <email@hidden>
References: 
 >Finder's "exists" command ignores leading zero's in filename (From: Bert Groeneveld <email@hidden>)
 >Re: Finder's "exists" command ignores leading zero's in filename (From: Luther Fuller <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
  • 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