[LON-CAPA-cvs] cvs: loncom /homework/CAPA-converter/conversion_wrapper convert.pl

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 16 Feb 2005 20:31:06 -0000


albertel		Wed Feb 16 15:31:06 2005 EDT

  Added files:                 
    /loncom/homework/CAPA-converter/conversion_wrapper	convert.pl 
  Log:
  - adding felicia's directory conversion script
  
  

Index: loncom/homework/CAPA-converter/conversion_wrapper/convert.pl
+++ loncom/homework/CAPA-converter/conversion_wrapper/convert.pl
#!/usr/bin/perl

if ($#ARGV != 1) {
  print "Correct command usage: \n";
  print "   perl convert.pl [DIRECTORY_TO_CONVERT] [NEW_DIRECTORY]\n";
}

$olddir = $ARGV[0];
$newdir = $ARGV[1];

@problem = `ls -B $olddir/ | grep -v bak`;
chomp @problem;

for($index=0;$index<=$#problem;$index++) {
  $newprob = $problem[$index];
  $newprob =~ s/txt/problem/;
#  $newprob = $newprob.".problem";
  open( CONVERT, ">$newdir/$newprob" );
  print CONVERT "<problem>\n";
  $convert =
`/home/felicia/loncapa/loncom/homework/CAPA-converter/Linux/convert -f
$olddir/$problem[$index]`;
  print CONVERT "$convert";
  print CONVERT "\n</problem>\n";
  close CONVERT;
}