Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

cag8f

Re: How to delete all files in a directory except the three most recent?

OK gotcha, thanks.
martin

Re: How to delete all files in a directory except the three most recent?

Management of local files have nothing to do with WinSCP.
cag8f

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

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.