I need to remove the "_1331045422" from image files in my directory.
for eg., my image file name looks like: message-16-error_1331045422.png
I actually ran a script which rename all image files this way. Also I have other files (image files with correct names, js files and css etc. which have correct names)
Please help me with a command to rename all image files with the "_1331045422" , without affecting others.
EDIT: I not only have .png files with the wrong filename. There are gifs and jpegs too.
Make a backup of your files before trying this!!
With rnm:
More examples here.
You can use rename command:
rename 's/_\d+(\..{1,3})/$1/g' *
You can change the range between {} if you have files with extension longer than three chars.
Be carefull that on some system the rename command is a bit different. Have a look here: https://superuser.com/questions/70217/is-there-a-linux-command-like-mv-but-with-regex