Advertisement
iamliam

Batch Rename PHP

Dec 30th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.25 KB | None | 0 0
  1. #!/usr/bin/php
  2. <?php
  3.  
  4. $files = glob("./backup-*.tar.gz");
  5. foreach ($files as $file) {
  6.     $data = explode(".", $file);
  7.     $month = substr($file, 9, 1); // Accounts for the ./backup-
  8.     exec("mv -f {$file} _temp_{$data[2]}{$data[1]}{$month}.tar.gz");
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement