Question : Need shell script to rename all files in a directory

I'm a Unix noob.  I need to rename all the files in a directory by adding a suffix.  This script will run on Fedora Remix running on an XO netbook from the OLPC foundation.  I think it runs the Bourne shell, but it may be a limited version of it.

The files all have 8 character names.  First character is a letter, the next 7 are numbers, and there is a .jpg suffix.  I want to rename them so there is a three character string before the suffix.  For example, original name: P1234567.jpg, new name P1234567.abc.jpg where 'abc' is a string I can change in the script file.

I wish to change the name so I can add some basic info to the file name so I can categorize files when it comes time to manually rename them with names that indicate what the picture's content is.

The rename process should not create copies of the files with new names, just rename them. I expect to make copies of the files before I run the rename script, so there is no need for the script to make copies.  The script should act on all files in the current directory.

I access the internet about once a day and it's probably when you're asleep (I'm in the Philippines) so please be patient when waiting for my response.

Answer : Need shell script to rename all files in a directory

perl -e '($r=$_)=~s/\.jpg/.abc.jpg/ and rename $_,$r or die "$_,$r $!" for '
Random Solutions  
 
programming4us programming4us