Re: adding leading zeros to a filename
From: Kevin Rodgers (ihs_4664_at_yahoo.com)
Date: 01/28/05
- Next message: Heiner Steven: "Re: mail alert depending on output"
- Previous message: Heiner Steven: "Re: Script with bash -i can't access tty?"
- In reply to: rupert: "Re: adding leading zeros to a filename"
- Next in thread: alan_at_ljubljana.agtrz.com: "Re: adding leading zeros to a filename"
- Reply: alan_at_ljubljana.agtrz.com: "Re: adding leading zeros to a filename"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 Jan 2005 14:36:47 -0700
rupert wrote:
> Basically I know nothing about shell scripting. I'm guessing I can
> write such a beast that will list the contents of a directory
for file in *.jpg; do
...
done
or
ls *.jpg | while read file; do
...
done
> and rename
> the files as it goes.
mv $file $new_file
> I'm an apple OSX user, so not a unix guru and have had a look through
> stuff on perl and regular expressions and although I sort of understand
> some of it I've not managed to work out how to make it do what I want.
> I can write c, c++, and c# stuff on pc's (the day job) so am not a
> novice when it comes to software, but don't have a unix background at
> all - adn shell scripts/perl/grep etc are unknown territory. So
> basically was hoping for an expert to tell me how to do it! ...and this
> looked like a promising place to ask...
`man sh` is a good place to start. But I prefer ksh:
typeset -Z3 number
for file in *.jpg; do
number=${file%.jpg}
mv $file $number.jpg
done
-- Kevin Rodgers
- Next message: Heiner Steven: "Re: mail alert depending on output"
- Previous message: Heiner Steven: "Re: Script with bash -i can't access tty?"
- In reply to: rupert: "Re: adding leading zeros to a filename"
- Next in thread: alan_at_ljubljana.agtrz.com: "Re: adding leading zeros to a filename"
- Reply: alan_at_ljubljana.agtrz.com: "Re: adding leading zeros to a filename"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|