I need a script that moves incoming files from my FTP to a location on my sy
stem and once moved, deletes them from my FTP.
I am already this far:
set {f1, f2} to {“Volumes/ftp.enfocus.com/incoming/PA Test JeroenD”, “/Users
/JeroenD/Desktop/FTP Test”}
tell application “Finder”
move every file of folder f1 to folder f2
end tell
Error says: Impossible to obtain every file of folder
How come? End what about the deleting part? Thanks!
set {f1, f2} to {"Volumes:ftp.enfocus.com:incoming:PA Test JeroenD" as alias, "Macintosh HD:Users
:JeroenD:Desktop:FTP Test" as alias}
tell application "Finder"
move every file of folder f1 to folder f2
end tell
Finder will usually understand a variety of path identifiers, including (in no particular order):
As you’ve discovered, what doesn’t work in this context is a Unix-type path:
The bridge between Unix and traditional Mac forms is Posix: Unix paths can be coerced to other classes via Posix file, while Posix path facilitates conversion in the other direction.
So, if you need Finder to do some work, use a form other than a Posix path (as, for example, j already suggested). If you have no choice in what you’re starting out with (such as when another operation has already served up Posix paths), then you’ll need to add a further step - something like:
set {f1, f2} to {"Volumes/ftp.enfocus.com/incoming/PA Test JeroenD", "/Users/JeroenD/Desktop/FTP Test"}
set {f1, f2} to {f1 as POSIX file, f2 as POSIX file}
tell application "Finder" to move folder f1's files to folder f2
Now i need the files on the FTP to be deleted.
As soon as there is a new file on the FTP is needs to be copied to the folder
so i was thinking about an “every 5 minutes re-run” (or something else)
If this could be possible it would be fantastic!!!
If you plan to do a fair amount of scheduling, then it might be worth checking out cron(8), crontab(1) and crontab(5). (And if the technical stuff causes your eyes to glaze over, take a look, also, at CronniX - now available as a Universal binary.)
However, for occasional jobs like this, my own personal preference would be to use a script - saved as a stay-open application, and containing an idle handler.