Is there any way to get a directory listing, and replace the spaces in EVERY file with underscores or remove the spaces?
Ty
Every File NAME that is
Try..
if ( $dir = @opendir("[i]<Your Directory>[/i]") ) { while ( ($file = readdir($dir) ) !== false ) { $file = preg_replace("/\\s*/","_",$file); echo "$file\n"; } closedir($dir); }
Err..Perhaps I didn't clerify myself, I actually want to rename the files, not just display what it would be renamed to...
if ( $dir = @opendir("[i]<Your Directory>[/i]") ) { while ( ($file = readdir($dir) ) !== false ) { $newfile = preg_replace("/\\s*/","_",$file); if ( ! rename($file, $newfile) ) { die("Problems Renaming...."); } } closedir($dir); }