Topic "How to delete all files in a directory except the three most recent?"

Author Message
cag8f
[View user's profile]

Joined: 2014-06-25
Posts: 9
Hi all. I have a WinSCP script that automatically downloads a file from my remote directory to a local directory. This occurs once a week, and I would like to add additional code to my script so that my local directory keeps at most three such backups. How might I approach that? I gather the rough logic would be:

* Count number of files in local directory (this directory stores only these backup files--nothing else).
* If number of files is greater than three, delete the oldest file.

Thanks in advance.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26150
Location: Prague, Czechia
Management of local files have nothing to do with WinSCP.
cag8f
[View user's profile]

Joined: 2014-06-25
Posts: 9
OK gotcha, thanks.
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