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.
----------------------------------------------------------- # IF the file ~/Downloads/test.txt DOES already exist. ----------------------------------------------------------- set _alias to alias ((path to downloads folder as text) & "test.txt") set posixPath to POSIX path of _alias set posixFile to POSIX file posixPath
tell application "Finder" exists _alias --> true
exists POSIX file posixPath --> false
exists posixFile --> true
tell AppleScript to exists POSIX file posixPath --> true
end tell -----------------------------------------------------------
and trying to get the script to wait for the file to appear using:
Your script should complete the do shell script call before continuing to execute.
A fully working demonstration:
------------------------------------------------------------------------------------------- set downloadDir to "~/Documents/curl-test-ccs/" set _cmd to "mkdir " & downloadDir & "; echo " & downloadDir set downloadDir to do shell script _cmd
delay 0.1
set _cmd to " cd " & quoted form of downloadDir & " " do shell script _cmd
delay 0.1
set _fldr to alias (POSIX file downloadDir) tell application "Finder" set fileList to files of _fldr as alias list if length of fileList = 3 then activate open _fldr set newFolder to make new folder at _fldr with properties {name:"A_Sub_Folder"} move fileList to newFolder open newFolder else error "ERROR: Incorrect file count!" end if end tell
-------------------------------------------------------------------------------------------
* I am a bit surprised that you're using the Finder instead of staying in the shell.
-- Best Regards, Chris
|