I am trying to rename a few hundred files based on another file in the same directory. I found a script and with modification I have the following:while read file; do echo mv \${file%/*}/Trailer.mov\ \${file%.*}-Trailer.mov\; done < <(find . -type f ! -name Trailer.mov -name *.mkv)It outputs mv commands like so:mv ./dir1/Trailer.mov ./dir1/filename-Trailer.movThe mv commands do rename the files correctly (if it exists) when I run it manually. When I run the script without echo it gives errors like so:mv: cannot stat ./dir1/Trailer.mov: No such file or directoryThis error happens for every single item regardless of the files existence. Whyd does this happen? I am running as root.
Rename bash script - false no such file or directory error
bash;shell script;mv
You must either remove the inner quotes or use eval.The problem is that the s are now considered part of the file name i.e. the wrong file name (which does not exist) is tried to be accessed.