title: Update timestamp of files being renamed
body: <p>I am recursively bulk renaming files in a directory using the rename function (thanks to Markus Zeller for code):</p>
  <pre><code> $search = 'image1';
   $replace = 'great';
   $path = '/path/to/files/';
   $iterator = new RecursiveDirectoryIterator($path);
   foreach(new RecursiveIteratorIterator($iterator) as $file) {
   if ($file-&gt;isFile() &amp;&amp; str_contains($file-&gt;getFilename(), $search)) {
      @rename($file-&gt;getPathName(), str_replace($search, $replace, $file-&gt;getPathName()));
   }
   }
  </code></pre>
  <p>This works great, but the renamed files haven't had their timestamp updated to the current date/time (they retain their original creation date).  I have tried adding the &quot;touch()&quot; command but it instead creates empty files (0 bytes):</p>
  <pre><code> touch(@rename($file-&gt;getPathName(), str_replace($search, $replace, $file-&gt;getPathName())));
  </code></pre>
  <p>The reason I need the time of the files changed is because I am renaming cache files and need the creation date to be current.
  If anyone has a solution that would be great thanks.</p>