I need to download 800 files from a server to my server. These files have different names and they're in different subdirectories in the remote server, but I have their names on a list. How can I do this on a way that I don't have to go one by one? I can use scp or sftp, but I don't know how to submit a list of files to be downloaded.

Thanks a lot!

migrated from stackoverflow.com Apr 29 '13 at 20:41

This question came from our site for professional and enthusiast programmers.

  • What OS do you have on the server you want to download the files to? – Martin Prikryl Apr 29 '13 at 18:07
  • oops! sorry I forgot to mention, they're both Linux servers. – user2283859 Apr 29 '13 at 18:16
  • What programming language are you using? – Andrew Savinykh Apr 29 '13 at 20:34

You should be able to do something like:

wget http://the.source.of.it.all $(< /the/list/of/files/here)

or even run the whole by a script that iterates over the files reading a line from the list and asking for it.

How much do you know of shell programming? How well do you know the command line Unix utilities? Are you familiar with a scripting language, like Perl or Python?


sftp has a -b option to read commands from a batch file. The batch file should contain a list of commands like you would type at the sftp> command prompt.

You could generate a batch file containing get commands for each file that you want to fetch, along with any other commands that you need to issue, like lcd or lmkdir to put the files in the correct local directories.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy