2

I have directories test1-test10 in a remote FTP server. Using WinSCP scripting, I want to retrieve every file under these directories.

This shows all directories:

ls test*

I want to retrieve all the files inside these directories:

get test*/*

However I get an error saying no such file or directory.

How can I accomplish this?

drum
  • 689

3 Answers3

1

Use synchronize not get. The get command only downloads from the current directory. Synchronize is recursive.

WinSCP Scripting Commands

get - Downloads file from remote directory to local directory

synchronize - Synchronizes remote directory with local one

Edit: Synchronize will get everything. If it's likely that the directories will not change, I'd recommend putting the ten individual get commands into a script.

get test1/*
get test2/*
...
get test10/*
Steven
  • 27,892
  • Synchronize is downloading everything including the directories test1-10. All I want are the files inside of the directories. My filemask is /test*/*. – drum Aug 17 '15 at 17:17
  • I might have said I have test1-10, but this is my mock example. In reality I have around 500 of these directories. Manually typing each directory is not the most feasible solution for me. – drum Aug 17 '15 at 18:51
1

Use

get test*

If there no other directories in the remote directory, you can even use:

get *
1

My workaround was a batch script:

set num=1,2,3
for %%i in (%num%) do ( WinSCp.com /command ^
                        "open <user>:<password>@<hostname>:<port>" ^
                        "get test%%i/* <destination>" ^
                        "exit")

This will create a new connection per directory, but it was the best I could do.

drum
  • 689