I have a lot of files that have a shared pattern in their name that I would like to remove. For example I have the files, "a_file000.tga" and "another_file000.tga". I would like to do an operation on those files that would remove the pattern "000" from their names resulting in the new names, "a_file.tga" and "another_file.tga".
Try this (this works in plain old Bourne sh
as well):
for i in *000.tga
do
mv "$i" "`echo $i | sed 's/000//'`"
done
Both arguments are wrapped in quotes to support spaces in the filenames.
Bash can do sed
-like substitutions:
for file in *; do mv "${file}" "${file/000/}"; done