I have a single file (a PDF) and I want to have lots of identical copies in the same folder (200 would be nice) named file-001
, file-002
etc.
How do I do it?
I have a single file (a PDF) and I want to have lots of identical copies in the same folder (200 would be nice) named file-001
, file-002
etc.
How do I do it?
This is the classic case where shell tricks help a lot.
And I know it's a joke, but if you want a random
_
or-
separating the number from the name you can use:(multiple line to help readability...)
:-P
You could do something like
however if the medium becomes unreadable it will not matter how many copies are on it - fundamentally backups require diversity.
Note that
tee
writes its standard input to standard output as well as to each of the given files - for large files, or for files containing binary data or other special characters that may interfere with your terminal settings, you will probably want to dump standard output to the bit bucketTo make a single duplicate of a file you probably know that you can use
cp
:Now, to make more duplicates to a file, you can combine
cp
withxargs
. In your case:will copy
file
tofile-001
,file-002
,... ,file-200
. Seeman xargs
for more info.As always, the python truck comes late, but:
make it executable, drag it over a terminal window, drag the file to copy over the terminal window and set the number of copies:
The number of leading zeros is set automatically, the files are named
file_001.pdf
,file_002.pdf
, with the filenumbers placed before the extension.The script: