How do I Remove Specific Characters From File Names Using BASH

Viewed 69979

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".

5 Answers

Use rename, maybe you need to install it on linux, Its python script

rename (option) 's/oldname/newname' ...

so you can use it like

rename -v 's/000//' *.tga

that means we are instructing to replace all files with .tga extension in that folder to replace 000 with empty space. Hope that works

You can check this link for more info and here

Related