[mdlug] batch name changes
Garry Stahl
tesral at wowway.com
Fri Jan 25 07:01:17 EST 2013
On 01/24/2013 02:50 PM, Ingles, Raymond wrote:
> Sure. A loop on the files, and use the "-b" option to the "file" command, and the "cut" utility, and you're just about set.
>
> Here's an example:
>
> #!/bin/sh
>
> # Helps handle filenames with spaces
> IFS=`printf '\n\t'`
>
> for FILE in $*
> do
> echo $FILE
> IS_IMAGE=`file -b $FILE | cut -f2 -d" "`
> if [ "image" = "$IS_IMAGE" ]; then
> IMAGE_TYPE=`file -b $FILE | cut -f1 -d" "`
> case $IMAGE_TYPE in
> GIF)
> echo "It's a gif!"
> mv $FILE $FILE.gif
> ;;
> JPEG)
> echo "It's a jpeg!"
> mv $FILE $FILE.jpg
> ;;
> *)
> echo "I dunno what to do with image type " $IMAGE_TYPE
> ;;
> esac
> fi
> done
>
I understood not a word of that. I have no idea how to put it into
practice.
--
Garry AKA --Phoenix-- Rising above the Flames.
I have as much authority as the Pope, I just don't have as many people who believe it.
Star Trek mort. Viva la Star Trek admiraetur
The Olde Phoenix Inn http://phoenixinn.iwarp.com
Metro Detroit Linux Users Group http://www.mdlug.org
More information about the mdlug
mailing list