Index: trunk/ippScripts/scripts/detrend_reject_imfile.pl
===================================================================
--- trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 11297)
+++ trunk/ippScripts/scripts/detrend_reject_imfile.pl	(revision 11298)
@@ -19,5 +19,5 @@
 use Pod::Usage qw( pod2usage );
 
-my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $no_update);
+my ($det_id, $iter, $exp_tag, $det_type, $camera, $filter, $reject, $dbname, $workdir, $no_update);
 GetOptions(
 	   'det_id|d=s'        => \$det_id,
@@ -29,4 +29,5 @@
 	   'reject'            => \$reject
 	   'dbname|d=s'        => \$dbname, # Database name
+	   'workdir|w=s'       => \$workdir, # Working directory, for output files
 	   'no-update'         => \$no_update,
 	   ) or pod2usage( 2 );
@@ -68,10 +69,13 @@
 }
 
-my $example = ${$files}[0]->{b1_uri}; # Example file
-my ($vol, $dir, $file) = File::Spec->splitpath( $example );
+unless (defined $workdir) {
+    my $example = ${$files}[0]->{b1_uri}; # Example file
+    my ($vol, $dir, $file) = File::Spec->splitpath( $example );
+    $workdir = $dir;
+}
 
 # Generate the file list, and get the statistics
 my $outputRoot = $exp_tag . '.detresid.' . $det_id . '.' . $iter; # Root output name
-$outputRoot = File::Spec->catpath( $vol, $dir, $outputRoot );
+$outputRoot = File::Spec->catfile( $workdir, $outputRoot );
 $outputRoot = $ipprc->convert_filename_absolute($outputRoot);
 my $list1Name = $outputRoot . '.b1.list'; # Name for the input file list for binning 1
