I am using a MacBook Pro OS X 2013 model.
I have a list of filenames in a text file named list.txt
separated by line breaks
list.txt exactly like this, but this list is going to be long
e.jpeg
x.jpeg
a.jpeg
m.jpeg
p.jpeg
l.jpeg
e.jpeg
I need these commands to copy the same files to the destination folder thousands of times and I am running into the duplicate file name problem. I need it to copy the files over again but I figure if I rename them sequentially as they are copied to the new folder, then I won't run into the duplicate names. I am copying the same approx. 40 files over and over again thousands of times depending on the order that they appear in list.txt
. Each file is between 100KB and 250KB.
I want to copy each file in the order that they are listed in list.txt
to another folder and rename them sequentially
I used this to copy the files to the new folder and it worked sort of, it didn't keep or rename the duplicates.
cp `cat list.txt` new-folder/
I am using this to rename them sequentially, but it renames them in the wrong folder
find . -name '*.jpeg' \
| awk 'BEGIN{ a=0 }{ printf "mv %s %04d.jpeg\n", $0, a++ }' \
| bash
I have been trying to combine them using this with no luck:
cat [filename] | while read line; do [command] "$line"; done
I've tried a bunch of combinations of this:
cp `cat list.txt` new-folder/ | while read line; do find . -name '*.jpeg' \
| awk 'BEGIN{ a=0 }{ printf "mv %s %04d.jpeg\n", $0, a++ }' \
| bash "$line"; done
I need the files to appear in the newfolder in the order of list.txt, because I am going to use them by the date added/date creation for the project. I might have to put a delay for each line until it is coppied and renamed.