I am trying to write a bash script that will go through a directory and rename the files (the file name is really crazy and is not recognizable to any human as what they are) to "Chapter1.mp3", "Chapter2.mp3", etc, but when I do this, I get the following error:
mv: target 'Chapter##.mp3' is not a directory
As I recall, the mv
command allows you to specify a filename as well as a directory... why am I getting this error? The following is my code:
cptr=0;
for i in ./myFolder/*; do
cptr=$(($cptr+1)); # I can't remember, can I use cptr++?
mv -v $i "Chapter$cptr.mp3";
done;
I've tried removing the file extension, removing the quotes, even using the cp
command instead, but nothing I have tried has worked.
Why is it requiring the target to only be a directory and not a filename?
I am using the Ubuntu 20.04 LTS terminal with Linux Subsystem for Linux; does this make any difference?