Renaming multiple files

Hi,

I have several hundred files I need to rename, and I'm would rather not hit F2 for each file individually to rename them.

Example of file:
large1961.jpg
What I need the file to be renamed as:
1961.jpg

I don't know what type of command I can execute within a shell script that would remove a specific unwanted part of the file name ("large") and leave the rest intact.

I am an obvious novice in shell scripting and would appreciate any help.
Thanks in advance.

many ways...one is:

#  echo large1981.jpg | sed 's/large//'
1981.jpg

Thanks.

So in order to actually rename the file, how could I take the output of that command and make it the final file name?

$ rename
Usage: rename [-v] [-n] [-f] perlexpr [filenames]

... if you have rename I would go that route ...

rename 's/^large(.*)/$1/' large*.jpg

Thanks a lot. That did what I needed it to, and saved a lot of time on my part.

Could you explain the options you used in the command? I read the man page, but I'm not exactly sure what each parameter actually means.

:cool: if all of the files start with large or even a similar structure try this;

^large1967.*^1967.*

Folks, It all worked fine until i hit a filename with spaces in between.. how do i overcome this?
ex..
i tried on files "a.txt", "b.txt", "c d.txt", i got..
mv: cannot stat `c': No such file or directory
mv: cannot stat `d.txt': No such file or directory

Thanks,
OT

Here is a script to replace spaces with underscore of all files in a directory.
You should be able to edit this to do what you want.

#! /bin/bash
# blank-rename.sh
#
# Substitutes underscores for blanks in all the filenames in a directory.

ONE=1                     # For getting singular/plural right (see below).
number=0                  # Keeps track of how many files actually renamed.
FOUND=0                   # Successful return value.

for filename in *         #Traverse all files in directory.
do
     echo "$filename" | grep -q " "         #  Check whether filename
     if [ $? -eq $FOUND ]                   #+ contains space(s).
     then
       fname=$filename                      # Yes, this filename needs work.
       n=`echo $fname | sed -e "s/ /_/g"`   # Substitute underscore for blank.
       mv "$fname" "$n"                     # Do the actual renaming.
       let "number += 1"
     fi
done   

if [ "$number" -eq "$ONE" ]                 # For correct grammar.
then
 echo "$number file renamed."
else 
 echo "$number files renamed."
fi 

exit 0