Announcement

Collapse
No announcement yet.

wget save a file as...

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    wget save a file as...

    I'm using wget to pull down four files, and save them all to a single folder. The problem is that while they are all different files, each of them have the same file name on the original servers. I would like to have wget save each one under a different file name. Is it possible to have wget rename the files as they are saved, or is there another solution that might work just as well?
    The main reason I'm using wget is because I can have a list of files for it to get in one txt file, without me having to start each one separately.

    Example:
    (on the server)
    /folder1/file.txt
    /folder2/file.txt

    (on my computer)
    /folder/file1.txt
    /folder/file2.txt

    #2
    Re: wget save a file as...

    Code:
    USER # wget [url]http://penguin.ch/repository/bash/aptToDate.sh[/url]
    [url]http://penguin.ch/repository/bash/aptToDate.sh[/url] => `aptToDate.sh'
    USER # wget [url]http://penguin.ch/repository/bash/aptToDate.sh[/url]
    [url]http://penguin.ch/repository/bash/aptToDate.sh[/url] => `aptToDate.sh.1'
    USER # wget [url]http://penguin.ch/repository/bash/aptToDate.sh[/url]
    [url]http://penguin.ch/repository/bash/aptToDate.sh[/url] => `aptToDate.sh.2'
    You get the idea

    Comment


      #3
      Re: wget save a file as...

      wget [option]... [URL]...

      Download Options
      -nc
      --no-clobber

      If a file is downloaded more than once in the same directory, Wget's behavior depends on a few options, including -nc. In certain cases, the local file will be clobbered, or overwritten, upon repeated download. In other cases it will be preserved.

      When running Wget without -N, -nc, or -r, downloading the same file in the same directory will result in the original copy of file being preserved and the second copy being named file.1. If that file is downloaded yet again, the third copy will be named file.2, and so on. When -nc is specified, this behavior is suppressed, and Wget will refuse to download newer copies of file. Therefore, ``"no-clobber"'' is actually a misnomer in this mode---it's not clobbering that's prevented (as the numeric suffixes were already preventing clobbering), but rather the multiple version saving that's prevented.

      When running Wget with -r, but without -N or -nc, re-downloading a file will result in the new copy simply overwriting the old. Adding -nc will prevent this behavior, instead causing the original version to be preserved and any newer copies on the server to be ignored.

      When running Wget with -N, with or without -r, the decision as to whether or not to download a newer copy of a file depends on the local and remote timestamp and size of the file. -nc may not be specified at the same time as -N.

      Note that when -nc is specified, files with the suffixes .html or (yuck) .htm will be loaded from the local disk and parsed as if they had been retrieved from the Web.
      Windows no longer obstructs my view.
      Using Kubuntu Linux since March 23, 2007.
      "It is a capital mistake to theorize before one has data." - Sherlock Holmes

      Comment


        #4
        Re: wget save a file as...

        Originally posted by UnicornRider
        Code:
        USER # wget [url]http://penguin.ch/repository/bash/aptToDate.sh[/url]
        [url]http://penguin.ch/repository/bash/aptToDate.sh[/url] => `aptToDate.sh'
        USER # wget [url]http://penguin.ch/repository/bash/aptToDate.sh[/url]
        [url]http://penguin.ch/repository/bash/aptToDate.sh[/url] => `aptToDate.sh.1'
        USER # wget [url]http://penguin.ch/repository/bash/aptToDate.sh[/url]
        [url]http://penguin.ch/repository/bash/aptToDate.sh[/url] => `aptToDate.sh.2'
        You get the idea
        I'm sorry, I didn't make myself clear. I'm familiar with the *.1, *.2, etc. I'm looking for a way to rename the file to the a name I select. I've read the man page, but didn't find anything - I'm not sure if I've missed anything or if it is ever possible.

        What I'm trying to do is pull down my calendars form my Google Calendars, I have four of them to download. They all save as basic.ics, which is no use to me for importing them into my calendar program. I want to be able to pull them all down quickly before move someplace without an internet connection.

        I suppose I could just write a small script to automate the process. wget a file, rename it, wget the second file, rename it, etc.; though I would prefer an already made solution, if one exists.

        Comment


          #5
          Re: wget save a file as...

          Originally posted by Mythos
          I'm looking for a way to rename the file to the a name I select.
          Code:
          wget bla
          mv bla blub

          Comment


            #6
            Re: wget save a file as...

            wget -O outputfilename http://address.of.file/to/get

            (Note capital O; "-O -" outputs to standard output rather than a file)

            Comment

            Working...
            X