What am I missing here, this seems so simple yet I cant get it to work.
I have a directory with files like AGPNDRAH01.jpg
I want a directory with files like AGPNDRAH01_00.jpg
rename 's/(\w+).jpg\$1\_00.jpg$//' *
Doesnt, work. Centos linux. Makes no sense to me why this isnt working.
Quick hack that will do what you describe in bash:
For rename usage:
Try the following bash script:
That will find all .jpg files in or below the current directory and insert
_00
before.jpg
. If you only want it to handle the current directory start the find command withfind . -maxdepth 1
Double backslash at the end of the regex means substitute s/(\w+).jpg$1_00.jpg$ with an empty string.
I used this:
I am not familiar with rename, but your regex doesn't look right. It appears like you are trying to match files named like this AGPNDRAH01.jpg.AGPNDRAH01_00.jpg and change their name to nothing.
Are you sure you don't mean something like this instead?
I have a variant of redhat, and rename doesn't support the 's/' command. Here's a one-liner for you (You have to backslash parenthesis and plus-signs to get the functionality in sed):
You just had a slash in the wrong place and an unnecessary backslash.