Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to download multiple files and need to rename as I download, how can I do that and specify the directory I want them to download to? I know i need to be using -P and -O to do this but it does not seem to be working for me. I'm writing this into a php script and running on unix.

share|improve this question

1 Answer 1

You have to either specify the -P or the -O, for example:

wget --directory-prefix="/home/admin/" http://someurl

OR

wget --output-document="/home/my_new_file_name" http://someurl

In the first example it will download anything you want to the specified directory and at the 2nd example it will download the file with the new given name to the given directory.

share|improve this answer
1  
You may also want to look at curl and the -o and --create-dirs options; there's ways to dynamically specify the filenames based on portions of the URL being fetched. For example: "curl http://www.example.com/{foo,bar}.html -o 'example_#1.txt'" will create example_foo.txt and example_bar.txt. –  freiheit Aug 4 '10 at 20:56
    
i also agree with freiheit, if you have curl available it is probably your best option since you are doing it with a php script. –  Prix Aug 4 '10 at 21:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.