[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell scripting



you can save the script as batchzip.sh
then make it an executable..
>chmod 755 batchzip.sh
and then run it
>./batchzip.sh

HTH,
Pritpal Dhaliwal

aurel.ric@free.fr wrote:

How do you call your script?

Aurel

Quoting Pete Clarke <pete@dynotechnic.co.uk>:

Hi there people,

I have a script that performs batch zipping of files. Trouble is that it
only does one file at a time (kind of going against the "batch" idea).
Could someone point out the silly mistake I am obviously making?

Chers,


Pete.

--------------------------------------------------------------

#!/bin/sh
#
# batch zip
# invoke with batchzip <filespec>
#
# this will zip all files in the current directory that conform
# to the file spec.
#
ZIP="/usr/bin/zip"
ARGS="-mT"

if [ -n "$1" ]
then
   if [ -x "$ZIP" ]
   then
       nofiles=0

       for file in "$1"
do
           filename=${file%.*}
           echo "Adding $file to $filename.zip..."
           $ZIP $ARGS "$filename" "$file" > /dev/null

           let "nofiles += 1"
       done

       echo
       echo "finished ... processed $nofiles files."
       echo
       retval=0
   else
       echo
       echo "Could not find 'zip'. Please check the path."
       echo
       retval=2
   fi
else
   echo
   echo "Usage : `basename $0` <filespec>"
   echo
   retval=1
fi

exit $retval



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact
listmaster@lists.debian.org









Reply to: