From: Vincent Vanwaelscappel Date: Thu, 28 Aug 2025 08:53:02 +0000 (+0200) Subject: #7702 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5707c953b156499432ada9197f7b4c7c6e6dd9ce;p=cubist_util.git #7702 @0.25 --- diff --git a/src/Files/Files.php b/src/Files/Files.php index 4b74eb2..713510e 100644 --- a/src/Files/Files.php +++ b/src/Files/Files.php @@ -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