Last active
December 20, 2015 00:19
-
-
Save magickatt/6040703 to your computer and use it in GitHub Desktop.
Convert a directory of files into a directory of directories with the same names
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 | |
$directories = scandir('/some_directory'); | |
array_shift($dirs); | |
array_shift($dirs); | |
$baseDirectory = '/another_directory'; | |
foreach($directories as $directory) { | |
$filename = current(explode('.', $directory)); | |
$newDirectory = $baseDirectory . $filename; | |
mkdir($newDirectory); | |
echo "Created " . $newDirectory . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment