|
@@ -18,11 +18,22 @@
|
|
|
// not of significant concern.
|
|
// not of significant concern.
|
|
|
$remove_self = false;
|
|
$remove_self = false;
|
|
|
|
|
|
|
|
|
|
+// If true, the script will show a preview of all discovered files and dir-
|
|
|
|
|
+// ectories. See the setting "$max_preview_size" for maximum preview results.
|
|
|
|
|
+$enable_dir_scan_preview = true;
|
|
|
|
|
+
|
|
|
|
|
+// If true, the script will spew the full command immediately prior to its
|
|
|
|
|
+// execution during the final renaming process.
|
|
|
|
|
+$display_full_cmd = true;
|
|
|
|
|
+
|
|
|
|
|
+// If true, the script will spew the progress during the rename operation.
|
|
|
|
|
+$display_progress = true;
|
|
|
|
|
+
|
|
|
// If true, directories will be skipped and thus will not be renamed.
|
|
// If true, directories will be skipped and thus will not be renamed.
|
|
|
$skip_directories = true;
|
|
$skip_directories = true;
|
|
|
|
|
|
|
|
-// Maximum results per preview group.
|
|
|
|
|
-$count_group_size = 100;
|
|
|
|
|
|
|
+// Maximum results per preview.
|
|
|
|
|
+$max_preview_size = 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -160,6 +171,8 @@ else{
|
|
|
exit(1);
|
|
exit(1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+echo " > Performing initial directory traversal, please wait...\n";
|
|
|
|
|
+
|
|
|
$contents = array();
|
|
$contents = array();
|
|
|
GET_DIR_CONTENTS($dirToTraverse, $contents);
|
|
GET_DIR_CONTENTS($dirToTraverse, $contents);
|
|
|
|
|
|
|
@@ -174,13 +187,32 @@ if ($remove_self){
|
|
|
|
|
|
|
|
// var_dump($contents);
|
|
// var_dump($contents);
|
|
|
|
|
|
|
|
-echo " > FILE AND DIRECTORY LIST:\n ================================\n";
|
|
|
|
|
-foreach ($contents as $c){
|
|
|
|
|
-
|
|
|
|
|
- echo " " . $c . "\n";
|
|
|
|
|
-}
|
|
|
|
|
|
|
+echo " > Initial directory traversal complete.\n";
|
|
|
|
|
+
|
|
|
|
|
+$counter = 0;
|
|
|
|
|
+$stop_preview = false;
|
|
|
|
|
+
|
|
|
|
|
+if ($enable_dir_scan_preview){
|
|
|
|
|
+
|
|
|
|
|
+ echo " > ORIGINAL FILE AND DIRECTORY PREVIEW:\n ================================\n";
|
|
|
|
|
+ foreach ($contents as $c){
|
|
|
|
|
+
|
|
|
|
|
+ if ($stop_preview)
|
|
|
|
|
+ break;
|
|
|
|
|
+ $counter++;
|
|
|
|
|
+
|
|
|
|
|
+ if ($counter > $max_preview_size){
|
|
|
|
|
+
|
|
|
|
|
+ echo " --------- (results truncated)\n";
|
|
|
|
|
+ $stop_preview = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ echo " " . $c . "\n";
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-echo " ================================\n";
|
|
|
|
|
|
|
+ echo " ================================\n";
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
$content_map = array();
|
|
$content_map = array();
|
|
|
$content_map_new = array();
|
|
$content_map_new = array();
|
|
@@ -226,7 +258,7 @@ foreach ($content_map as $p => $f){
|
|
|
|
|
|
|
|
$counter++;
|
|
$counter++;
|
|
|
|
|
|
|
|
- if ($counter > $count_group_size){
|
|
|
|
|
|
|
+ if ($counter > $max_preview_size){
|
|
|
|
|
|
|
|
echo " --------- (results truncated)\n";
|
|
echo " --------- (results truncated)\n";
|
|
|
$stop_preview = true;
|
|
$stop_preview = true;
|
|
@@ -267,7 +299,10 @@ if (ARE_STRINGS_EQUAL($begin_operation, "Y", true)){
|
|
|
|
|
|
|
|
$new_path = dirname($p) . "/" . $content_map_new[$p];
|
|
$new_path = dirname($p) . "/" . $content_map_new[$p];
|
|
|
$cmd = "mv \"" . $p . "\" \"" . $new_path . "\"";
|
|
$cmd = "mv \"" . $p . "\" \"" . $new_path . "\"";
|
|
|
- echo " >>> " . $cmd . "\n";
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if ($display_full_cmd)
|
|
|
|
|
+ echo " >>> " . $cmd . "\n";
|
|
|
|
|
+
|
|
|
exec($cmd);
|
|
exec($cmd);
|
|
|
}
|
|
}
|
|
|
|
|
|