Reputation: 385
I want to list a list of files using wget. There are relatively different URLs in the list.
If the same file name is downloaded twice, but from another domain, the file is renamed and a number is added as a file extension.
I would like the file name to be counted up and not the file extension. Can I use wget to adjust the schema so that the filenames are counted up or do I have to write an additional script that fixes it afterwards? Can you help me?
Start wget:
wget -nv -i "files.txt" --directory-prefix=files;
Contents of files.txt:
http://example.com/apple.jpg
http://example.org/apple.jpg
http://example.net/apple.jpg
Downloaded files:
apple.jpg
apple.jpg.1
apple.jpg.2
Desired filenames: (example)
apple.jpg
apple-1.jpg
apple-2.jpg
Upvotes: 1
Views: 630
Reputation: 385
I am afraid as well, putonspectacles. I have made here my solution purely.
rename -v 's/\.(jpeg|jpg|png|gif)\.(\d{1,3})$/_$2\.$1/' *
Upvotes: 1