1. match the specified keyword to find the file 2. after matching the file, execute the corresponding system command or generate a batch file. 3. feedback execution result 4. example: $ phpfind. phpd: photo.jpg, .gif, .png gmconvert-resize200X200 $ filename $ filename5. example explanation: Find all folders and subfolders under d: photo jpg, gif, png
1. match the specified keyword to find the file 2. after matching the file, execute the corresponding system command or generate a batch file. 3. feedback execution result 4. example: $ phpfind. phpd:/photo.jpg, .gif, .png gmconvert-resize200X200 $ filename 5. for example, find all the folders and subfolders under d:/photo. jpg, gif, And. png.
1. Match the specified keyword to find the file
2. After matching the file, execute the corresponding system command or generate a batch file.
3. Feedback execution results
4. Example: $ php find. php d:/photo .jpg,.gif, .png "gm convert-resize 200X200 $ filename"
5. Example explanation: Find all the folders and subfolders under d:/photo in jpg, gif, and png formats. Call GraphicsMagick to convert the size to 200*200 and overwrite the original files. <无>
read())) { if($currentPath[strlen($currentPath) - 1] == '/') { $filename = $currentPath . $name; } else { $filename = $currentPath . '/' . $name; } if($name == '..' || $name == '.') { continue; } if(is_dir($filename)) { $directory[] = $filename; } else { str_replace(explode(',', $match), '', $name, $count); if($match != '*' && $count == 0) { continue; } $template = array('$name', '$filename', '$path', '$index'); $variable = array($name, $filename, $currentPath, $index); $cmd = str_replace($template, $variable, $command); if(CREATE_BAT_FILE) { $result .= $cmd . PHP_EOL; } else { echo shell_exec($cmd); } $index++; } } next($directory);}// create bat fileif(CREATE_BAT_FILE) { $batFile = fopen('temp.bat', 'w'); fwrite($batFile, $result); fclose($batFile); echo 'output file to: ' . str_replace('\\', '/', __DIR__) . '/temp.bat' . PHP_EOL;}// echo result:echo $index . ' file find.' . PHP_EOL;