Skip to content

Instantly share code, notes, and snippets.

@rmpel
Created March 10, 2021 09:37
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 rmpel/b4a575c3fc96f90396cb40d39f393bac to your computer and use it in GitHub Desktop.
Save rmpel/b4a575c3fc96f90396cb40d39f393bac to your computer and use it in GitHub Desktop.
File/Folder crawler; list all files and folders in a CSV file
<?php
/** QUICK AND VERY DIRTY */
header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename=crawl.csv');
?>
type,path,timestamp,date
<?php
___T(__DIR__);
function ___T($s) {
$l = array_merge( glob($s .'/.*'), glob($s .'/*') );
natcasesort($l);
foreach ($l as $e) {
$b = basename($e);
if ($b == '.' || $b === '..' || !trim($b)) {
continue;
}
if (is_dir($e)) {
echo '"d","' . $e . '",' . filemtime($e) . ',"' . date('r', filemtime($e)) .'"' ."\n";
___T($e);
}
else {
echo '"f","' . $e . '",' . filemtime($e) . ',"' . date('r', filemtime($e)) .'"' ."\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment