: ########################################################################## # Title : copylist - copy files in list of names to DOS disk # Author : Heiner Steven # Date : 1994-03-10 # Requires : mcopy # Category : File Utilities # SCCS-Id. : @(#) copylist 1.2 04/02/18 ########################################################################## # Description: # Note # o Needs non-standard program # mcopy ########################################################################## PN=`basename "$0"` # Program name VER='1.2' Usage () { echo "$PN - copy files in file list to DOS disk, $VER (stv '94)" echo "usage: $PN [-m] [-v] [listfile]" echo " -m: modify original file list" echo " -v: verbose output" echo echo "With argument -m, the names of successfully copied files" echo "are removed from the file list." echo "Reads standard input if no file list was specified." exit 1 } # Fatal (Msg ...) - print message to stderr, then exit Fatal () { for i do echo "$PN: $i" >&2 done exit 1 } Msg () { [ $Verbose = no ] && return 0 for i do echo "$PN: $i" done } Tmp=${TMPDIR:=/tmp}/cl$$ # Temporary file List=$TMPDIR/cl$$.l # File list Verbose=no Orig=no # change original list set -- `getopt 'hmv' "$@"` || Usage while [ $# -gt 0 ] do case "$1" in -v) Verbose=yes ;; -m) Orig=yes ;; --) break ;; -h|-*) Usage ;; esac shift done shift # '--' from getopt if [ $# -lt 1 ] then # no list: read stdin [ $Orig = yes ] && Usage # cannot modify standard input cat > $List || Fatal "cannot create file: $List" elif [ -r "$1" ] then if [ $Orig = yes ] then List="$1" else cp "$1" $List || Fatal "cannot copy list: $1" fi else Fatal "cannnot read file: $1" fi # Remove temporary files trap "rm -f $Tmp; [ $Orig = no ] && rm -f $List" 0 trap "exit 1" 1 2 3 15 while [ -s "$List" ] do Name=`head -1 "$List"` # first line Msg "Name $Datei" mcopy -n $Name a: || Fatal "cannot copy file: $Datei" # Remove first line from file tail +2 $List > $Tmp && mv $Tmp $List done exit 0