Re: How to "mass" renaming files

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: MCR
Date:  
To: joe, Main PLUG discussion list
Subject: Re: How to "mass" renaming files
Here is a script that I have been using a lot lately,
it is a simple shell scripts:

#!/bin/bash
number=12
for img in  *.jpg
do
        mv $img $number.jpg
        $((number = number + 1))
done


this will take all file in a directory that ends in
jpg and will rename it to the name of $name. You can
set $name to start at what number you want and it will
increment by one. I have gone as high as 253
pictures, I do not know what number it will stop at.

Hope it Helps.

Mike


--- Josef Lowder <> wrote:

>
> Can anyone provide a simple shell script command to 
> change the file names of all the files in a given
> directory? 
>     from pict0001.jpg to just 01.jpg 
>     from pict0002.jpg to just 02.jpg etc. etc. 
> with the numbers running to a few hundred pix, all
> with 
> the same "pict00..." first part of the filename. 

>
> I looked on the 'net to find a shell script to
> "mass" rename the files
> in any given directory and found the example below
> to rename the
> suffix from php3 to just php, but I couldn't figure
> out how to modify
> that to change the filename itself.
>
> ls -d *.php3 | sed 's/\(.*\).php3$/mv "&"
> "\1.php"/' | sh
>
> I also found a *nix utility on my system named
> 'rename' but I
> couldn't get it to work. Below is an excerpt from
> the 'man' page
> for 'rename' ... but what in the world is 'foo'??
>
> MAN PAGE excerpt:
> rename will rename the specified files by replacing
> the first occurrence of from in their name by to.
> For example, given the files foo1, ..., foo9, foo10,
> ..., foo278, the
> commands
>
> rename foo foo0 foo?
> rename foo foo0 foo??
>
> will turn them into foo001, ..., foo009, foo010,
> ..., foo278.
> And
> rename .htm .html *.htm        will fix the extension of
> your html files. 

>
> ---------------------------------------------------
> PLUG-discuss mailing list -
>
> To subscribe, unsubscribe, or to change you mail
> settings:
>

http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>



One is led to truth through the interpretation of a myth.

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss