[X-Unix] Re: Help batch renaming files with two "extentions"
Timothy Luoma
lists at tntluoma.com
Wed Mar 23 19:47:50 PST 2005
On Mar 23, 2005, at 8:33 PM, David Haines wrote:
> I've had success batch-renaming files named according to standard
> practice:
>
> filename.gif
>
> for example.
>
> I'm faced with a large number of files named:
> filename.w01.tif
>
> filenmae.w07.tif
>
> etc.
>
> and need to be able to strip all of them of : .tif
>
> This is certainly beyond my limited-but-slowly-growing shell-scripting
> abilities.
First of all, you ought to have Fink and/or DarwinPorts installed, and
then you can install GNU Coreutils easily. Using DP it's a simple
port install coreutils
(I think Fink is just 'fink install coreutils')
Once you have coreutils, you'll find you have a whole lot of useful
utilities such as 'basename' which would make this dirt simple
#!/bin/sh
for FILENAME in *.tif
do
short=`basename $FILENAME .tif`
mv -iv "$FILENAME" "$short"
done
# eof
More information about the X-Unix
mailing list