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'`"; done
I 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:
.......
echo
command 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%.*}
. – zrajm Sep 6 '13 at 8:40bash
(orzsh
for that matter) then thesed
invocation is not necessary either. Use${f// /_}
to replace all occurances of space with underscore in$f
. – zrajm Sep 6 '13 at 8:43