I have to convert multiple video files in a folder. I have to rename each one of them but I need the script to prompt me to write a custom name for each filename. Here is what I've got so far:
First I need to remove the filename spaces which my script does with that command:
for f in *' '*; do mv "$f" "`echo $f | sed -e 's/ /_/g'`"; doneI remove the extension of the files because I don't need it for the conversion. I use this command:
for x in *; do mv $x $(echo ${x%*.*}); done
After that I need a for loop to rename each file in the pattern:
for i in * ; do mv $i $customname; done
The problem is that I need in that phase the script to prompt me what name to add in the variable $customname for each file. Something like this:
Rename file1 to:
.......
Rename file2 to:
.......
echocommand in$(echo ${x%*.*})is completely superfluous. – And if you're just looking to remove the file extension you should not be using*.*(which is only incidentally working because the first asterisk is matching zero characters every time), instead use.*. I.e.$(echo ${x%*.*})should be${x%.*}.bash(orzshfor that matter) then thesedinvocation is not necessary either. Use${f// /_}to replace all occurances of space with underscore in$f.