Delete Remote files without deleting remote folder locations

Advertisement

sreyes
Joined:
Posts:
1
Location:
California

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.

Reply with quote

Advertisement

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

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.

Reply with quote

Advertisement

You can post new topics in this forum