Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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

martin

Re: Delete Remote files without deleting remote folder locations

WinSCP cannot ignore subfolders with the rm command.
But if the files you are deleting have specific extension(s), you can limit deleting to that extension(s):
rm /cr/dbhome/D0096T31/import/*.ext<180D

Otherwise you will have to use a more powerful language. Like a PowerShell script with use of WinSCP .NET assembly.
sreyes

Delete Remote files without deleting remote folder locations

Hello,

I am trying to create a command that will delete files over 180 days old from a directory without deleting the subfolders. I have created the following command line, but it is constantly deleting the sub-folders.
"[[WinSCP]]\WinSCP.exe" /log="L:\Sergio\Logs\UECUtest.log" /ini=nul /command "open sftp://sreyes:Yuri0922%21@172.29.222.123/ -hostkey=""ecdsa-sha2-nistp256 256 9+2BeP7RkAVy3f6NPWlQVCPx94raY9fGud+hLGrfiWY""" "rm /cr/dbhome/D0096T31/import/*<180D" "exit"

The folders are structured as follows:
/cr/dbhome/D0096T31/import/test1/

/cr/dbhome/D0096T31/import/test2/
/cr/dbhome/D0096T31/import/test3/
/cr/dbhome/D0096T31/import/test4/
/cr/dbhome/D0096T31/import/test5/

I have attempted to use a -filemask but to no success. Any guidance is greatly appreciated.