#! /bin/csh -f # Last modified on Thu Jul 10 15:25:32 1986 by stolfi #------------------------------------------------------------------ # Usage: move-news-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. # Also applies trim-headers to each file as it is moved. #------------------------------------------------------------------- if ($#argv < 2) then echo 'Usage: move-news-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 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 cat $f | sed -f /udir/stolfi/bin/trim-headers.sed > $folder/$i && rm $f end