• 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: Christopher Stone <email@hidden>
  • Date: Fri, 11 Jul 2014 14:49:30 -0500

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.

-----------------------------------------------------------
# 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 & "
curl --remote-name-all -L --user-agent 'Opera/9.70 (Linux ppc64 ; U; en) Presto/2.2.1' \"http://members.aceweb.com/randsautos/photogallery/ferrari/enzo/Ferrari-Enzo-[001-003].jpg\";
"
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

 _______________________________________________
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

  • Follow-Ups:
    • Re: get Applescript to act on a file once it has been downloaded
      • From: Luther Fuller <email@hidden>
References: 
 >get Applescript to act on a file once it has been downloaded (From: William Adams <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