I'm trying to write a script that will copy all file listed in a text file, around 3 million lines, which contains two columns, the source and the destination with a new filename:
All files are PDF format, where Newfilename.pdf is the new filename for the same source PDF file.
ADDITIONALLY, I would like to copy the file and add information to its destination filename, i.e.:
Newfilename_yyyyMMddHHmmss.pdf (e.g. Newfilename_20200225095823.pdf)
yyyyMMddHHmmss is the actual copy executing date and time for each file and this is the same format for all, causing the destination file to be copied with its complemented name:
I do not have enough knowledge to handle commands, an idea of what I was researching is the following:
while read -r source destination; do
# reading each value
cp -p source destination
done < $filename
However, I read some similar publications, for performance, the while loop and read are tremendously slow when reading from a file or a pipe, because the read shell built-in reads one character at a time. Reference here.
How it could be done with a better solution?
I will greatly appreciate your help.