#! /bin/csh -f # Last modified on Fri Jul 11 08:21:04 1986 by stolfi #------------------------------------------------------------------ # Usage: move-messages message... folder # Moves the given files to the specified folder, renumbering them. # The folder need not be empty; the new numbering will begin at # (last message in folder) + 1. The operation stops with an error # if the folder is or becomes full (>=999 messages). Files that do # not fit in the folder are not touched. #------------------------------------------------------------------- if ($#argv < 2) then echo 'Usage: move-messages ... ' exit(1) endif set folder = $argv[$#argv] if (! -d $folder) then echo $folder is not a directory exit(1) endif @ nfiles = $#argv - 1 set files = ($argv[1-$nfiles]) touch $folder/dummy rm -f $folder/+cur set i = `(echo 0; ls $folder) | sed -n '/^[0-9][0-9]*$/p' | sort -n | tail -1` foreach f ($files) @ i++ if ($i > 999) then echo "Folder $folder full, 999 messages or more." echo "Messages from $f on not moved." exit(1) endif echo $f ' -> ' $i mv -i $f $folder/$i end