27 Jun 15:36
Re: Rename multiple files at once
From: Marian Hettwer <mh <at> kernel32.de>
Subject: Re: Rename multiple files at once
Newsgroups: gmane.os.openbsd.misc
Date: 2007-06-27 13:36:42 GMT
Subject: Re: Rename multiple files at once
Newsgroups: gmane.os.openbsd.misc
Date: 2007-06-27 13:36:42 GMT
Hi Pieter,
On Wed, 27 Jun 2007 14:37:07 +0200, Pieter Verberne <pieterverberne <at> xs4all.nl> 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 :)
RSS Feed