Reputation: 872
I am downloading some files from database by using wget but some of the files in database named same. So, when I download 2 files with the same name, the files break. I wonder if there is a way to keep both files. For example I downloaded file named a.png and I download another different file but with the same name and change the name into a 2.png
Simply I just need something that recognize the file with the same name and gives different name to the 2nd, 3rd, 4th, ...
thank you..
Upvotes: 2
Views: 2405
Reputation: 872
I guess there is no way to do it with "-O". So, I kept that there and modified the program. I checked if the name of the file exist before I download. If it is exit I download the file like this "name$i.png". And also, I wrote the name of the file, which is exist, into .txt file. So, later on I will change them manually.
Upvotes: 0
Reputation: 784958
Use wget -nd
option to make sure it clobbers existing file.
As per man wget
:
-nd
--no-directories
Do not create a hierarchy of directories when retrieving recursively. With this
option turned on, all files will get saved to the current directory, without
clobbering (if a name shows up more than once, **the filenames will get
extensions .n**).
Also I like to add this:
When running Wget without -N, -nc, -r, or -p, 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. (This is also the behavior with -nd, even if -r or -p are in effect.) When -nc is specified, this behavior is suppressed, and Wget will refuse to download newer copies of file.
Upvotes: 1