• 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: get Applescript to act on a file once it has been downloaded
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get Applescript to act on a file once it has been downloaded


  • Subject: Re: get Applescript to act on a file once it has been downloaded
  • From: Luther Fuller <email@hidden>
  • Date: Fri, 11 Jul 2014 16:47:28 -0500

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,
______________________________________________________________________

Hey William,

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.




 _______________________________________________
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

References: 
 >get Applescript to act on a file once it has been downloaded (From: William Adams <email@hidden>)
 >Re: get Applescript to act on a file once it has been downloaded (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: get Applescript to act on a file once it has been downloaded
  • Next by Date: Re: get Applescript to act on a file once it has been downloaded
  • Previous by thread: Re: get Applescript to act on a file once it has been downloaded
  • Next by thread: Re: get Applescript to act on a file once it has been downloaded
  • Index(es):
    • Date
    • Thread