Search code examples
wgetnaming

How to handle similar names in wget?


I'm downloading so many images that their links are inside a file with the command:

wget -i file.txt

I suspect many of the files might have the same names. So I'm afraid they will be overwritten. is there anyway to make wget set sequential names to the file or handle similar names in any other way?


Solution

  • For wget 1.19.1, what you're looking for is the default behavior. Files that have the same names will be numbered when a matching file is found.

    Assuming that file.txt looks like:

    http://www.apple.com
    http://www.apple.com
    http://www.apple.com
    http://www.apple.com
    

    The output of wget -i file.txt will be four files, named:

    index.html
    index.html.1
    index.html.2
    index.html.3