Skip to content

Instantly share code, notes, and snippets.

@cornelisonc
cornelisonc / generate-file-dirs.php
Last active August 29, 2015 14:21
Create file directory structure for downloadable Magento products & move files accordingly
<?php
foreach (new DirectoryIterator('files/') as $file) {
if ($file->isFile()) {
$file_name = $file->getFilename();
$name = strtolower($file_name);
$letter1 = $name[0];
$letter2 = $name[1];
// Create first directory
if (!file_exists('media/downloadable/files/links/' . $letter1)) {