Created
June 25, 2022 08:12
-
-
Save Kovah/ed9851cd020448215d86cade3b663c55 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Randomizes the names of all files in the current directory | |
// Use with caution! | |
$files = scandir(__DIR__); | |
$files = array_filter($files, fn($file) => !in_array($file, ['.', '..', 'randomize.php', '.DS_Store'])); | |
echo 'Renaming ' . count($files) . 'files now'; | |
shuffle($files); | |
foreach ($files as $file) { | |
$new = hash('crc32', $file) . time() . '.' . pathinfo($file, PATHINFO_EXTENSION); | |
var_dump("Renaming $file to $new"); | |
rename(__DIR__ . '/' . $file, __DIR__ . '/' . $new); | |
} | |
echo 'Done'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment