Topic "Downloading only new files from a remote dir"

Author Message
hmir

Guest


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.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
This seems as too complex task for the simple scripting functionality of WinSCP.
However, what about:
Code:
option batch abort
get *
rm *

This would remove the files, if "get" succeeds, only.
Then you can run another script like:
Code:
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.
_________________
Martin Prikryl

Last edited by martin on 2005-08-26; edited 1 time in total
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24552
Location: Prague, Czechia
Let me know if it helps.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License