Skip to content

Instantly share code, notes, and snippets.

@magickatt
Last active December 20, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save magickatt/6040703 to your computer and use it in GitHub Desktop.
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
<?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