It is necessary to perform a file search. For this I use:

$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath)); // где $rootPath - директория, в которой нужно перебрать файлы 

How to remember where the iterator stopped when the script was previously run? It is necessary that the files that have already been moved do not participate in the new search.

PS You can use another method of brute force, the main thing that it was recursive

  • Yes, as always: throw in a file, database or memcache / analog. If it is a one-time, then a file is enough; if not, it is possible that the history in the database will be useful. - etki
  • What to throw in the file? - co11ter

0