abhi_madhani

Files scan

Jan 1st, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('memory_limit', '1024M');
  4.  
  5. $source_root = dirname(__FILE__) . "/files/";
  6. $source_iter =
  7. new RecursiveIteratorIterator(
  8. new RecursiveDirectoryIterator($source_root, RecursiveDirectoryIterator::SKIP_DOTS)
  9. );
  10.  
  11. $files_count = iterator_count($source_iter);
  12.  
  13. $i = 0;
  14. $fp = fopen(dirname(__FILE__) . "/files.csv", 'w');
  15.  
  16. foreach ($source_iter as $file) {
  17. if ($file->isFile()) {
  18. $info['#'] = ++$i;
  19. $info['filepath'] = $file->getRealPath();
  20. $info['atime'] = $file->getATime();
  21. $info['ctime'] = $file->getCTime();
  22. $info['mtime'] = $file->getMTime();
  23. $info['perms'] = $file->getPerms();
  24. $info['size'] = $file->getSize();
  25. $info['owner'] = $file->getOwner();
  26. $info['group'] = $file->getGroup();
  27. $info['hash'] = hash_file('sha256', $file->getRealPath());
  28.  
  29. fputcsv($fp, $info, ',', '"');
  30.  
  31. echo "$i -> $files_count -> {$info['filepath']} \n";
  32.  
  33. }
  34. }
  35.  
  36. fclose($fp);
  37.  
  38. ?>
Add Comment
Please, Sign In to add comment