[Novalug] help making shell script from command line that works

Eric Miller internetjanitor@gmail.com
Sat Jan 11 16:54:10 EST 2014


#!/bin/bash

from_extension=$1
to_extension=$2

if [ -z "$to_extension" ]; then
  echo "Usage: $0 <from> <to>"
  exit 1
fi

for file in *.$from_extension
do
  base_filename=${file%.*}
  echo Converting $file to ${base_filename}.$to_extension
  convert $file ${base_filename}.$to_extension
done



On Sat, Jan 11, 2014 at 4:37 PM, Bonnie Dalzell <bdalzell@qis.net> wrote:

> if any one has the time and patience:
>
> after some google searching I was able to construct this command line that
> works to batch convert a subdirectory of .TIF files to .png files.
>
> i would like a more general shell script I could point to a subdirectory
> of images and batch convert between formats. nothing really fancy - just
> to  be able to enter as variables the input image file type and the
> output image file type.
>
> sort of:
> changepicf TIF png
>
> i probably can write a perl script for it but writing perl scripts has
> caused me to not use/learn shell scripting much.
>
> this worked as a command line entry:
>
> for file in *.TIF; do convert $file $file.png;done
>
> thanks
>
> sorry to miss today's meeting. I want to come to some of them but getting
> up early enough to make it down to NoVa from north of Baltimore is a
> challenge. maybe I can find someone to car pool with.
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                         Bonnie Dalzell, MA
> mail:PO box 9767 Baldwin, MD, USA 21013  |  EMAIL:bdalzell@qis.net
> shipping address:5100 Hydes Rd 21082 (Hydes Post Office closed Jan 2012)
> Freelance anatomist, vertebrate paleontologist, writer, illustrator, dog
> breeder, computer nerd & iconoclast... Borzoi info at www.borzois.com.
> HOME www.batw.net    ART bdalzellart.batw.net  BUSINESS
> www.boardingatwedge.com
>
> _______________________________________________
> Novalug mailing list
> Novalug@calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.firemountain.net/pipermail/novalug/attachments/20140111/76a1b819/attachment.htm>


More information about the Novalug mailing list