Delete Remote-Files automatically, which are older then xxx

Advertisement

thoath
Joined:
Posts:
4

Delete Remote-Files automatically, which are older then xxx

Hi,
please help me. I looked for a script-possibility to delete remote-files on a server, which are older than xxx-Days. The Numer xxx of days (modification time) I want to configure. Is it possible?
Thanks
Thomas

Reply with quote

Advertisement

thoath
Joined:
Posts:
4

Thanks Martin,
Too bad that there's no easier way. I was hoping that I can use the "rm" command in WinSCP-use with a time parameter.
Unfortunately, I'm not really able to use javascript. Therefore, I can not use the variant likely. Do you have an example in VBS.
Ciao
Thomas

Reply with quote

Freitag
Freitag avatar
Joined:
Posts:
52

I don't have a unix server at hand, but you might be able to do it by setting up a remote command. View - Preferences - Commands - Add

Assuming your remote box is unix/Linux/OSX the following ought to work

find /path/to/your/dir/tree -atime +XXX -exec rm {}\;

Where XXX is the number of days older than which you want to delete the files.

You may need to use the -f argument with rm to avoid problems with it trying to run interactively.

This will DELETE files, test it manually in some safe directory first. find is recursive so it will also include directories below the one you indicate and I think it follows links.

Reply with quote

thoath
Joined:
Posts:
4

Thanks for Your Help,
I find now an own version:
I wrote a windows-bat with 3 commands:

Step 1: Synchronisize the remote-Folder with a local mirror-Folder

Step 2: Start a VB-Script which evaluate the Fileinformation of Files in the local-Folder --> and write a remove-joblist-File for WinSCP

Step 3: Execute the remove-joblist-File with WinSCP

It works fine, but it is not realy elegant.
Best regards and have a nice Christmas
Thomas

Reply with quote

AndroidFlo
Joined:
Posts:
1

Thank you all :) you saved me some time looks im not the only one need to remove some old files from time to time :)
_________________
linux Loves winSCP and i live it to :)

Reply with quote

cpezie
Guest

looks promising

Freitag wrote:

I don't have a unix server at hand, but you might be able to do it by setting up a remote command. View - Preferences - Commands - Add

Assuming your remote box is unix/Linux/OSX the following ought to work

find /path/to/your/dir/tree -atime +XXX -exec rm {}\;

Where XXX is the number of days older than which you want to delete the files.

You may need to use the -f argument with rm to avoid problems with it trying to run interactively.

This will DELETE files, test it manually in some safe directory first. find is recursive so it will also include directories below the one you indicate and I think it follows links.

I would like to use something like this except I want to remove any directories in the dir older then 7 days. So where you have -atime +XXX -exec rmdir -rf {}\ I need to know the syntax for days instead of time and what is the -XXX reference?

Thanks,

Reply with quote

Advertisement

You can post new topics in this forum