Hi Pieter,

On Wed, 27 Jun 2007 14:37:07 +0200, Pieter Verberne <[EMAIL PROTECTED]> wrote:
> Hi there,
> 
> How do I rename multiple files at once? I want to rename a list of
> files like:
> 
> file.jpg
> file1.jpg
> file_2.jpg
> 
> to:
> 
> file_thumb.jpg
> file1_thumb.jpg
> file_2_thumb.jpg
> 
Assuming that your files have only one . in their filename (just foo.jpg, not 
foo.bar.jpg), you could do this shell hack:

cd directory/with/your/files
for i in $(ls | cut -d. -f1); do echo "renaming ${i}"; mv ${i} ${i}_thumb.jpg; 
done

This is bourne shell syntax (works in my bash) and assumes that you only have 
one dot in your filename. Otherwise the "ls | cut -d. -f1" thing wouldn't work 
;)

Cheers,
./Marian

PS.: Yes, I know, there are probably safer ways of renaming :)

Reply via email to