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

lennelei

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 ;)

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

Thanks again.
Regards.
Alexis
martin

Re: Recursive get and delete files (but not the directories !)

This should work:
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

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

Hi,

I have a FTP server with the following directories:
/OUT/DIR1/

/OUT/DIR2/
/OUT/DIR3/

Within each directory, I may have one or more file named 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:
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:
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 :(

Any way to achieve this? I've seen in an old post that recursive delete was not supported by WinSCP in 2012:
Automatic delete files or folders matching a search term
but maybe today... ? :D

Thanks!