Results 1 to 5 of 5

Thread: Renaming downloaded files with wget?

  1. #1
    Join Date
    Apr 2006
    Location
    Lawrence, KS, USA
    Beans
    53
    Distro
    Ubuntu UNR

    Renaming downloaded files with wget?

    There are a bunch of files online "http://fake.url/334.pdf", "http://fake.url/5536.pdf" and "http://fake.url/2.pdf", say. I want to save them to my machine as "/foo/natasha.pdf", "/foo/wombat.pdf" and "/foo/tau.pdf" (where the directory "foo" does not yet exist).

    Priority is the renaming, directory placement is simple enough after the fact.

    Turning to wget's man, I find:

    -O file
    --output-document=file
    The documents will not be written to the appropriate files, but all will be concatenated together and written to file. ...
    I do not want to concatenate several files, but to simply rename them as I go, keeping them in separate files.

    Is this sort of "Save As..." unsupported by wget, in which case I should use some sort of script that combines wget with other tools?

    Or can I put a new -O file after every file to get these results I want?

    Is there another approach I'm missing?

    Thanks in advance for any suggestions you have!

  2. #2
    Join Date
    Sep 2007
    Location
    over there
    Beans
    2,424
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Renaming downloaded files with wget?

    I too long for renaming. But I haven't been able to find a suitable option in the manual. So I'm stuck with renaming after downloading.

    Of course, the man page is not the final authority. As it tell us:

    This is not the complete manual for GNU Wget. For more complete information, including more detailed explanations of some of the options, and a number of commands available for use with .wgetrc files and the -e option, see the GNU Info entry for wget.
    Maybe you'll find your solution there...
    "All people are scum. No matter what they look like." ~ Spider Jerusalem, Transmetropolitan #4
    blog


  3. #3
    Join Date
    Mar 2009
    Location
    Vancouver
    Beans
    7
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Renaming downloaded files with wget?

    You could use the -O option for single file wget's. Multiple files might require fancy bash'ing?

  4. #4
    Join Date
    Mar 2008
    Location
    England
    Beans
    Hidden!
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Renaming downloaded files with wget?

    Perhaps this fancy bash'ing will work?

    Code:
    echo "http://fake.url/334.pdf natasha.pdf
    http://fake.url/5536.pdf wombat.pdf
    http://fake.url/2.pdf tau.pdf" |
    awk '{print "wget "$1" -O "$2}' |
    bash
    I don't know how much of it makes sense, but just put it all in a script file (in your home dir), with a name like dlfiles.sh, and then run:

    Code:
    bash ~/dlfiles.sh
    For each in the echo statement, put in the URL, followed by the desired filename.

  5. #5
    Join Date
    Apr 2006
    Location
    Lawrence, KS, USA
    Beans
    53
    Distro
    Ubuntu UNR

    Re: Renaming downloaded files with wget?

    Just what I needed, thanks!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •