|
|
@@ -20,6 +20,9 @@ $remove_self = false;
|
|
|
// If true, directories will be skipped and thus will not be renamed.
|
|
|
$skip_directories = true;
|
|
|
|
|
|
+// Maximum results per preview group.
|
|
|
+$count_group_size = 100;
|
|
|
+
|
|
|
|
|
|
|
|
|
// ====================================================================================
|
|
|
@@ -154,6 +157,79 @@ foreach ($contents as $c){
|
|
|
|
|
|
echo " ================================\n";
|
|
|
|
|
|
+$content_map = array();
|
|
|
+$content_map_new = array();
|
|
|
+
|
|
|
+// Build a content map: array with path => filename format.
|
|
|
+foreach ($contents as $c){
|
|
|
+
|
|
|
+ if (is_dir($c))
|
|
|
+ $filename = null;
|
|
|
+ else
|
|
|
+ $filename = basename($c);
|
|
|
+
|
|
|
+ $content_map[$c] = $filename;
|
|
|
+}
|
|
|
+
|
|
|
+$content_map_new = $content_map;
|
|
|
+
|
|
|
+// print_r($content_map);
|
|
|
+// Build the replacement content map. This contains the same path => filename
|
|
|
+// format but with the updated filename instead of the original.
|
|
|
+foreach ($content_map_new as $p => $f){
|
|
|
+
|
|
|
+ // REPLACE2($str, $search, $replace)
|
|
|
+ $filename_new = REPLACE2($f, $regex_search, $replace_str);
|
|
|
+ $path_new = REPLACE2($p, $regex_search, $replace_str);
|
|
|
+ $content_map_new[$p] = $filename_new;
|
|
|
+}
|
|
|
+
|
|
|
+echo " > New content map created. See below for preview.\n";
|
|
|
+
|
|
|
+echo " > FILE AND DIRECTORY PREVIEW:\n ================================\n";
|
|
|
+
|
|
|
+/*
|
|
|
+
|
|
|
+$counter = 0;
|
|
|
+$counter_a = 0;
|
|
|
+$count_max = count($content_map);
|
|
|
+$last_key = "";
|
|
|
+
|
|
|
+*/
|
|
|
+
|
|
|
+foreach ($content_map as $p => $f){
|
|
|
+
|
|
|
+ if (!is_dir($p)){
|
|
|
+
|
|
|
+ $new_path = dirname($p) . "/" . $content_map_new[$p];
|
|
|
+ echo " [OLD]: " . $p . "\n";
|
|
|
+ echo " [NEW]: " . $new_path . "\n\n";
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ if ($counter + 1 < $count_max){
|
|
|
+ $counter++;
|
|
|
+ $counter_a++;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($counter_a >
|
|
|
+ */
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+
|
|
|
+echo " *** Please review above results carefully ***\n\n";
|
|
|
+echo " - To begin operation (cannot be undone), type 'Y' and press ENTER/RETURN.\n";
|
|
|
+echo " - To preview more results, type 'P' and press ENTER/RETURN.\n";
|
|
|
+echo " - To cancel script without making any changes, type 'N' and press ENTER/RETURN.\n";
|
|
|
+echo "\n >> Begin operation? [Y/N/P]: ";
|
|
|
+$response = fgets(STDIN);
|
|
|
+$begin_operation = substr($response, 0, strlen($response) - 1);
|
|
|
+
|
|
|
+*/
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|