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.