*';
$files = array_diff(scandir($path), ['.','..']);
foreach ($files as $fileName) {
$file = File::get()->filter('Name', $fileName);
if (!$file->count()) {
echo 'File name was not found at SS DB: '.$fileName.'
'.PHP_EOL;
continue;
}
foreach ($file as $f) {
if ($f->exists()) {
echo 'File #'.$f->ID.' already exists at SS file structure. '.$fileName.'
' . PHP_EOL;
continue;
}
echo 'Found non existing at SS file system file and found it at SS DB.'
.' Creating the file #'.$f->ID.' at SS file system. "' . $fileName . '"
' . PHP_EOL;
$f->setFromLocalFile($path.'/'.$fileName);
$f->write();
$f->publishFile();
}
}
die('Success!');
}
}