On Jul 11, 2014, at 2:49 PM, Christopher Stone wrote: On Jul 11, 2014, at 09:15, William Adams < email@hidden> wrote: Attempting to access it as an alias the fails though, ______________________________________________________________________
I don't see you using an alias in the code you showed.
The Finder doesn't like coercing to a Posix file. It will recognize a Posix file, but do the coercion outside the Finder's tell-block or embed a 'Tell AppleScript' statement as below if necessary.
* Posix file is a class of the Standard Additions osax.
I agree. In fact, using the full path name of a non-existing file can be a problem. Here is a quick experiment I just tried. And it worked.
I created a folder named "TESTING FOLDER" on my desktop and created a file named "testfile.rtf", also on the desktop. Then I ran this script ...
property folderAlias : alias "OS_X:Users:lutherfuller:Desktop:TESTING FOLDER" set filename to "testfile.rtf" repeat 100 times tell application "Finder" set fileExists to (exists file filename of folderAlias) end tell if fileExists then exit repeat delay 1 end repeat if fileExists then display dialog "File Exists!" buttons {"OK"} else display dialog "The file failed to appear." buttons {"OK"} end if
This script will wait patiently (you have more than a minute to act) for you to move the file "testfile.rtf" into the folder "TESTING FOLDER". When you do, the dialog will respond with "File Exists!".
The proper way to test for existence is the line ...
tell application "Finder" set fileExists to (exists file filename of folderAlias) end tell
which uses a file name (text) and an alias to the location where the file is to appear. This avoids all use of posix paths which seem to me to cause a problem for the Finder.
|