]> _ Git - cubist_util.git/commitdiff
#7702 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 28 Aug 2025 08:53:02 +0000 (10:53 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 28 Aug 2025 08:53:02 +0000 (10:53 +0200)
src/Files/Files.php

index 4b74eb228114ed24136b9eb572a860fbbdd7bf43..713510ed061db99135ec437a700c079388e44049 100644 (file)
@@ -431,6 +431,26 @@ class Files
         return $res;
     }
 
+    public static function recursiveReplaceStringInFilename($path, $replace = [])
+    {
+        $files = self::getRecursiveDirectoryIterator($path);
+        foreach ($files as $file) {
+            /** @var $file \SplFileInfo */
+            if ($file->isDir()) {
+                continue;
+            }
+
+            $path = $file->getPathname();
+
+            foreach ($replace as $k => $v) {
+                if (strstr($path, $k)) {
+                    rename($path, str_replace($k, $v, $path));
+                }
+            }
+
+        }
+    }
+
     /**
      * @param $search string
      * @param $replace string