I've been reading about Bulk rename, change prefix and would try with my own files.
In this case, I would like to remove Old and replace it with New
Test Files
01. Old Name.txt
02. Old Name.txt
03. Old Name.txt
Attempt 1
for f in *.txt
do
mv "$f" "New${f#Old}"
done
Output 1
New01. Old Name.txt
New02. Old Name.txt
New03. Old Name.txt
Attempt 2
for i in *.txt
do
mv ${i} ${i/#Old/New}
done
Output 2 (no changes)
user@linux:~$ for i in *.txt
> do
> mv ${i} ${i/#Old/New}
> done
mv: target 'Name.txt' is not a directory
mv: target 'Name.txt' is not a directory
mv: target 'Name.txt' is not a directory
user@linux:~$
What's wrong with my solution?
Desired Output
01. New Name.txt
02. New Name.txt
03. New Name.txt