Forráskód Böngészése

cleaner display based on progress and command display preference combinations.

Christopher 5 éve
szülő
commit
fb151bc0d3
1 módosított fájl, 30 hozzáadás és 6 törlés
  1. 30 6
      mass-rename.php

+ 30 - 6
mass-rename.php

@@ -3,8 +3,8 @@
 //	Copyright (c) 2020 DBMXPCA Technologies. All rights reserved.
 //	www.dbmxpca.com
 //	Date Created: May 18, 2020
-//	Last Updated: May 18, 2020
-//	     Version: 1.1
+//	Last Updated: May 19, 2020
+//	     Version: 1.03
 
 //	====================================================================================
 //	--- SETTINGS --- SETTINGS --- SETTINGS --- SETTINGS --- SETTINGS --- SETTINGS ---
@@ -35,6 +35,10 @@ $skip_directories = true;
 //	Maximum results per preview.
 $max_preview_size = 100;
 
+//	Number of characters to limit the full path & file command preview. This
+//	must be a negative number in order to display the last N characters.
+$cmd_display_limit = -32;
+
 
 
 //	====================================================================================
@@ -293,6 +297,8 @@ if (ARE_STRINGS_EQUAL($begin_operation, "Y", true)){
 		sleep(1);
 	}
 	
+	echo "\n  > Operation in progress, please wait...\n";
+	
 	$total_items = count($content_map) + 1;
 	$items_remaining = $total_items;
 	$curr_item = 0;
@@ -309,13 +315,31 @@ if (ARE_STRINGS_EQUAL($begin_operation, "Y", true)){
 			
 			
 			$new_path = dirname($p) . "/" . $content_map_new[$p];
+			//	Actual command to be executed.
 			$cmd = "mv \"" . $p . "\" \"" . $new_path . "\"";
+			//	Truncated command to be displayed.
+			$cmd_d = "-";
+			//	Make sure the strings are actually long enough to get truncated. If either are too short,
+			//	then just display the full command.
+			if (strlen($p) >= -$cmd_display_limit && strlen($new_path) >= -$cmd_display_limit){
+				$cmd_d = "mv \"..." . substr($p, $cmd_display_limit) . "\" \"..." . substr($new_path, $cmd_display_limit) . "\"";
+			}
+			else{
+				$cmd_d = $cmd;
+			}
 			
-			if ($display_progress)
+			if (!$display_progress && !$display_full_cmd){		//00
+				//	print nothing
+			}
+			else if (!$display_progress && $display_full_cmd){	//01
+				echo " >>> [" . $cmd_d . "]\n";
+			}
+			else if ($display_progress && !$display_full_cmd){	//10
 				echo " >>> [Progress:  " . $progress_val_d . "%  (" . $curr_item . "/" . $total_items . ") | Items Remaining: " . $items_remaining . "]\n";
-			
-			if ($display_full_cmd)
-				echo " >>> " . $cmd . "\n";
+			}
+			else if ($display_progress && $display_full_cmd){	//11
+				echo " >>> [Progress: " . $progress_val_d . "% (" . $curr_item . "/" . $total_items . ") | Remaining: " . $items_remaining . "] | [" . $cmd_d . "]\n";
+			}
 			
 			exec($cmd);
 		}