#!/bin/csh -f set homedir = $PWD set error_file = ~/public_html/data4.errors set backup_path = /data5/data4_backup if (-e $error_file) rm $error_file # Determine the number of data4 links set n_links = `wc -l data4.links | awk '{print $1}'` set n = 1 # Loop over the links and form a list of the directories holding them set dirs = () set old_dir = '' while ($n <= $n_links) set link = `tail -n +$n data4.links | head -n 1` set dir = `dirname $link` if ($dir != $old_dir) then set dirs = ($dirs $dir) endif set old_dir = $dir @ n ++ end # Loop over the directories holding data4 links and attempt to replace the link # with the data file itself. Log errors to $error_file foreach dir ($dirs) cd $dir if (! -e data_location) mkdir data_location set links = `find . -maxdepth 1 -type l | sed 's:./::'` foreach link ($links) if (! ( "$link" =~ *.tar* || "$link" =~ *.dat4 || "$link" =~ *.EXE || \ "$link" =~ *.zip || "$link" =~ *data ) ) then set source = `ls -l $link | awk '{print $NF}'` if( "$source" =~ /data4* ) then set file = $link set source = `echo $source | sed 's:/data4:/data5/data4_backup:'` cp $source $file.tmp >>& $error_file if ($status == 0) then mv $link data_location mv $file.tmp $file else # ls -l $link >> $error_file endif endif endif end cd $homedir end