I’m trying to test if a network file exists this failes even if the file does exists
set otherResult to "theFIlename"
set openfile to "/Volumes/Service Manuals/zzAll/" & otherResult & ".pdf"
tell application "Finder"
if not (exists POSIX file openfile) then
display dialog "fail"
end if
end tell
However this does work
tell application "Finder"
if not (exists POSIX file "/Volumes/Service Manuals/zzAll/theFilename.pdf") then
display dialog "fail"
end if
end tell
any help would be greatly appreciated.
The number 1 rule in applescript is you shouldn’t issue commands to the wrong application. If you look in the applescript dictionary for the Finder you will not find the “posix file” command. That command is part of the standard additions to applescript. As such you should issue that command to applescript itself and not the Finder. You are seeing an effect of issuing that command to the wrong application. In effect when you do that you can never be sure of the outcome. Your script should look like this…
set a to "/Volumes/FamilyLibrary/tagcache2.dat"
set b to POSIX file a
tell application "Finder"
if not (exists b) then
return "fail"
else
return "exists"
end if
end tell
thanks for your quick response. this is now working!