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