Index: trunk/ippScripts/scripts/automate_stacks.pl
===================================================================
--- trunk/ippScripts/scripts/automate_stacks.pl	(revision 28581)
+++ trunk/ippScripts/scripts/automate_stacks.pl	(revision 28609)
@@ -41,5 +41,5 @@
 # Grab options
 my ( $date, $camera, $dbname, $logfile, $verbose, $manual);
-my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $check_mode);
+my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $this_mode_only, $check_mode);
 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips);
 my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old);
@@ -60,4 +60,5 @@
     'this_target_only=s'   => \$this_target_only,
     'this_filter_only=s'   => \$this_filter_only,
+    'this_mode_only=s'     => \$this_mode_only,
     'check_registration'   => \$check_registration,
     'define_burntool'      => \$define_burntool,
@@ -87,4 +88,5 @@
            --this_target_only     Process only a single target.
            --this_filter_only     Process only a single filter.
+           --this_mode_only       Process only a single clean mode.
         Modes:
            --check_registration   Confirm the data downloaded correctly.
@@ -130,4 +132,5 @@
 my %detfilter_list = ();
 my %detmax_list = ();
+my @mode_list = ();
 my %clean_commands = ();
 my %clean_retention = ();
@@ -152,4 +155,5 @@
 	    if (${ $mentry }{name} eq 'MODE') {
 		$this_mode = ${ $mentry }{value};
+		push @mode_list, $this_mode;
 	    }
 	    elsif (${ $mentry }{name} eq 'COMMAND') {
@@ -264,4 +268,14 @@
     }
     die("$this_filter_only is invalid.") if ($#filter_list != 0);
+}
+
+if (defined($this_mode_only)) {
+    foreach my $t (@mode_list) {
+        if ($t eq $this_mode_only) {
+            @mode_list = ($this_mode_only);
+            last;
+        }
+    }
+    die("$this_mode_only is invalid.") if ($#mode_list != 0);
 }
 
@@ -842,5 +856,5 @@
     }
     if (($metadata_out{nsState} eq 'CHECKDETRENDS') && ($exposures > 0)) {
-	$metadata_out{nsState} eq 'QUEUE_DETRENDS';
+	$metadata_out{nsState} eq 'QUEUEDETRENDS';
     }
 }
@@ -1043,5 +1057,5 @@
     my $pretend = shift;
 
-    foreach my $mode (sort (keys (%clean_commands))) {
+    foreach my $mode (@mode_list) {
 	if ((exists($clean_alternate{$mode})) && ($clean_alternate{$mode} eq 'A')) {
 	    my ($cleaning_date,$command) = construct_cleantool_args($date,"",$mode);
