before writing this post, I obviously searched the internet and found several solutions that could perhaps work. But I'm a complete newbie to command line programming or writing.
What I have :
Thousands of image files stored in a parent directory with multiple sub-directories.
What I want to do:
Rename all of these files including those in the sub-directories using a CSV file with a comma separator. A typical row looks like this :
IMG_20221207_094623.jpg,photo_1.jpg
IMG_20221207_094627.jpg,photo_2.jpg
IMG_20221207_094651.jpg,photo_3.jpg
I found a post on this forum describing a command line using the sed function.
How to batch rename files (images) based on CSV file
To the almost identical question asked there (except for the sub-directories part), the following command line was proposed by @terdon
sed 's/"//g' files.csv | while IFS=, read orig new; do mv "$orig" "$new"; done
The solution provided by @terdon works fine for files in the current directory but does not process files in sub-directories, unless I haven't figured out how.
The return from the command line is as follows:
mv: cannot stat '20221207_094623 .jpg': No such file or directory
And if I try to add in my csv file in the origin column the full path of the file, I have this return
mv: cannot stat '/home/antoine.delauney/Images/00-Visite/20221207_094623.jpg': No such file or directory
For the first part of the {'s/"//g'} command, my file doesn't have quotes so I don't need to strip them like this sequence does. But I wasn't able to edit that first sequence without that the command line fails. If someone could guide me on this first part it would be very nice because I sometimes have to process batches of image files that are in a single directory.
However, the central question of this post is whether the sed command, directly or possibly with an additional command, is able to process a batch of files recursively by going to explore all the sub-directories from the given target? It will be very helpful !
Thank you in advance.
PS : I'm really sorry if my English doesn't always use the right terms. I am French, I speak a little English but for the purposes of this post I greatly helped myself from Google translate. There may therefore be inappropriate or unused terms (especially for examples of command line errors). My excuses.