I have a folder action, that calls a script to run a small automator script as follows
set myName to "admin"
set myPass to "PASSWORD"
set myFile to "~/Desktop/AutomationExersise/PDF/BusCardTemplate.pdf"
set myCurl to "curl -u " & myName & ":" & myPass & " ftp://rpm-repro.ftpstream.com/ -T " & myFile
do shell script myCurl
What I need to be able to do, is have the file name (BusCardTemplate.pdf) a variable which will be the name of the file, which will change on each occurance.
Then, once curl has done its bit, I need to delete the local file on my hard disk.
Can anyone give me a hand here?
Gratefully (as always)
Roy
Model: Powerbook G4
AppleScript: 1.10.7
Browser: Firefox 1.5.0.4
Operating System: Mac OS X (10.4)
Why call this from the folder action? Just put it in the FA. Assuming that you have tested the script and it works, and assuming that your folder action begins with a line like this:
on adding folder items to thisFolder after receiving theseItems
then theseItems will be a list of the items dropped on the folder. If you only drop one, it’s the first item of theseItems.
Try starting with something like this:
on adding folder items to thisFolder after receiving theseItems
repeat with aFile in theseItems -- assumed to be files, not folders
try
set tName to name of (info for (contents of aFile))
-- tName is the name of the one of the files in theseItems
-- do your FTP thing with the name like this:
set myFile to "~/Desktop/AutomationExersise/PDF/" & tName
-- etc. i.e. all the rest of your script
delete (contents of aFile)
-- I prefer to move them to my own "discard" folder so I can check before they go.
on error theError
display dialog theError -- in case something goes wrong; don't delete, tell me
end try
end repeat
end adding folder items to