I'm looking for an string through around 20.000 to 30.000 files located in the same folder at the same level (no subfolders).
One way to do it is by using the file_get_contents
function of PHP combined with strpos
, but I was wondering if it is possible to use console commands for this task as unix users can do in order to improve the performance.
Right now I'm using this:
$path = 'C:/myPath/';
$string = 'mySearchString';
$dir = new DirectoryIterator($path);
$results = array();
foreach ($dir as $file){
if (!$file->isDot()){
$content = file_get_contents($file->getPathname());
if (strpos($content, $string) !== false) {
$results[] = $file;
}
}
}
I've been taking a look at how to look for a string by using windows command lines, but I can not get it working with PHP.