D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Batch renaming of files



On Mon, 2003-08-25 at 19:30, Gemma Peter wrote:
> I got all the photos off the digital camera and saved them on my hard 
> drive (thanks to all those who helped at the Plymouth meeting). Now 
> gphoto has saved them to a directory with names in the format "-XXX.jpg" 
> where XXX is a three digit sequential number. How can I get rid of the 
> "-" at the beginning without having to rename each file individually?

This perl oneliner should do it OK, just make sure you are in the
directory where you have saved the photos. It should be all on one line.
Just copy that into a shell and it should do what you want.

perl -e 'foreach(<*>) { $new = $_ ; $new =~ s/-//g; rename $_ => $new;
}'

HTH

-- 
James 
jamesk[at]beeb[dot]net

"I think you just hit a nerve, the Vorlons must owe them money or
something." )Marcus Cole, B5 "Voices Of Authority")

Attachment: signature.asc
Description: This is a digitally signed message part


Lynx friendly