Topic "Recursive get and delete files (but not the directories !)"

Author Message
lennelei
[View user's profile]

Joined: 2015-10-14
Posts: 2
Location: France
Hi,

I have a FTP server with the following directories:

Code:
/OUT/DIR1/
/OUT/DIR2/
/OUT/DIR3/


Within each directory, I may have one or more file nammed "FILExxxxxxx.txt"

I wanted to write a WinSCP command to retrieve all files and then delete them, but without trying to delete the directories.

I first tried with this:
Code:
> winSCP.com /command "option batch abort" "option confirm off" "open SESSION" "cd /OUT/" "get -transfer=binary -delete -filemask=FILE*.txt * .\" "close" "exit"

If I don't use -delete option, it works, however, with the -delete option, it fails as it try to delete /OUT/DIR1 (and the user has no right for this hopefully).

I then tried with multiple filemask combination without success:
Code:
> winSCP.com /command "option batch abort" "option confirm off" "open SESSION" "cd /OUT/" "get -transfer=binary -delete -filemask=/OUT/*/FILE*.txt * .\" "close" "exit"
> winSCP.com /command "option batch abort" "option confirm off" "open SESSION" "cd /OUT/" "get -transfer=binary -delete -filemask=FILE*.txt;/OUT/*/ *" "close" "exit"
> winSCP.com /command "option batch abort" "option confirm off" "open SESSION" "cd /OUT/" "get -transfer=binary -delete -filemask=/OUT/*/FILE*.txt *" "close" "exit"


WinSCP always tries to remove directories Sad

Any way to achieve this? I've seen in an old post that recursive delete was not supported by WinSCP in 2012 but maybe today... ? Very Happy

Thanks!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25025
Location: Prague, Czechia
This should work:
Code:
winSCP.com /command "open SESSION" "get -transfer=binary -delete -filemask=/OUT/DIR1/FILE*.txt .\DIR1\" "exit"
winSCP.com /command "open SESSION" "get -transfer=binary -delete -filemask=/OUT/DIR2/FILE*.txt .\DIR2\" "exit"
winSCP.com /command "open SESSION" "get -transfer=binary -delete -filemask=/OUT/DIR3/FILE*.txt .\DIR3\" "exit"
lennelei
[View user's profile]

Joined: 2015-10-14
Posts: 2
Location: France
Hi,

thank you for the suggestion, actually, I wanted to avoid having to declare each directories as they might be subject to change.

I manage to make it work by using "option batch continue" instead, but it's not very nice Wink

Too bad that the delete option doesn't use the filemask as well! Maybe it could be a new feature?

Thanks again.

Regards.

Alexis
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