Downloading only new files from a remote dir

Advertisement

hmir
Guest

Downloading only new files from a remote dir

I need some help writing a script that would download any files from a remote dir and after download, delete them from remote dir. I know how to download and delete a remote file via script. The problem is that I only want to delete those files that have been downloaded successfully. If I was writing a unix shell script I know, I would read the list of files in a given dir, then using a foreach type loop, download each file at a time and then delete it if download was successful. I looked into synchronize command but that's not what I want to do. How can I accomplish this via WinSCP script. I would schedule this script using Windows Scheduler.

Any help. Thanks a lot.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,506
Location:
Prague, Czechia

Re: Downloading only new files from a remote dir

This seems as too complex task for the simple scripting functionality of WinSCP.
However, what about:
option batch abort
get *
rm *
This would remove the files, if "get" succeeds, only.
Then you can run another script like:
mv * to_some_back_up_dir/
To backup files that failed to download.
You can do that, if the first script returns error code, only.
Last edited by martin on 2005-08-26; edited 1 time in total

Reply with quote

Advertisement

You can post new topics in this forum