Topic "Delete Remote-Files automatically, which are older then xxx"

Author Message
thoath
[View user's profile]

Joined: 2011-12-14
Posts: 4
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
This example may give you some idea how to implement this:
https://winscp.net/eng/docs/script_download_most_recent_file
_________________
Martin Prikryl
thoath
[View user's profile]

Joined: 2011-12-14
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
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
Similar example in VB.NET:
https://winscp.net/eng/docs/guide_dotnet#vbnet_example
_________________
Martin Prikryl
thoath
[View user's profile]

Joined: 2011-12-14
Posts: 4
Thanks Martin,
Unfortunately, I can use on the computer no VB.Net, but only VBS.
Ciao Thomas
Freitag
[View user's profile]

Joined: 2007-10-25
Posts: 51
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.
thoath
[View user's profile]

Joined: 2011-12-14
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
AndroidFlo
[View user's profile]

Joined: 2011-12-21
Posts: 1
Thank you all Smile you saved me some time looks im not the only one need to remove some old files from time to time Smile
_________________
linux Loves winSCP and i live it to Smile
cpezie

Guest


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,
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24994
Location: Prague, Czechia
Recent versions of WinSCP support modification-time-based file masks:
https://winscp.net/eng/docs/file_mask#size_time
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