#!/usr/local/bin/perl # Reads the result of mdir $dir # writes a list of mcopy commands # # usage # mdir_2_com.p dir=lucidi # # feature not yet implemented: could write the commands to file # then "system" it. Or could directly "system" each command as it is # created. $file ="MCOM.tmp"; $doit = 0 ; $dir = "." ; # # process options on command line # eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; # open ( IN , "mdir $dir |" ) ; while ( ) { if ( /\/ || /Volume/ || /File/ || /Directory/ ) { next ; } $_ = substr ( $_ , 0 , 12 ) ; $_ =~ tr/A-Z/a-z/ ; if ( ( ($f,$xtn,$rest) = split ) && ($f ne "" ) && ($f ne "." ) && ($f ne ".." ) ) { print "mcopy\ta:$dir/$f\.$xtn\t$dir/$f\.$xtn\n" ; } } if ( $doit ) { chmod 0755, $file ; print $file , "\n" ; system $file ; } print $command2 , "\n" ; system $command2 ;