I am trying to copy and rename image files from one directory into another directory.
The files I want to copy have blank spaces embedded in their file names, and I want to replace part of the file name with the date that the image was taken.
Below is an example of the file names and the command that I have been using, along with an example of the error messages that I have been seeing.
For example, I would like to copy the "2008_08_17_Transfer 001.jpg" file from the source directory and rename it to "20090314001.jpg" in the target directory and so forth, for each file in the source directory that starts with "2008_08_17_Transfer ".
Here is what I tried and the error messages I see:
$ ls -l total 241968 -rw------- 1 stephen stephen 1347770 Mar 14 2009 2008_08_17_Transfer 001.jpg -rw------- 1 stephen stephen 1077919 Mar 14 2009 2008_08_17_Transfer 002.jpg -rw------- 1 stephen stephen 1359947 Mar 14 2009 2008_08_17_Transfer 003.jpg -rw------- 1 stephen stephen 1309175 Mar 14 2009 2008_08_17_Transfer 004.jpg -rw------- 1 stephen stephen 1404298 Mar 14 2009 2008_08_17_Transfer 005.jpg ... for i in *.jpg ; do scp -p "$i" /media/stephen/WDMyBook1_ext4/PicturesRenamedByDateTaken/2009/20090314/20090314`echo "$i" ` ; done 001.jpg: No such file or directory 002.jpg: No such file or directory 003.jpg: No such file or directory