Directories to look over -p Define RegEx patterns -r Rename file recursively -s Strings that will replace the matches Optional: -e Exclude defined pattern -l Output log file -t Test without modifying anything Example: php regRename.php -d ~/ -p "/(.+)_.+/" -s "\\1" Result: R File ".mysql_history" will be renamed to ".mysql" R File ".db_pass" will be renamed to ".db" R File ".bash_logout" will be renamed to ".bash" R File ".mysql_pass" will be renamed to ".mysql" R File ".bash_history" will be renamed to ".bash" php regRename.php -d ~/ -p "/(.+)_.+/" -s "\\1" __USAGE__ ) ; //------- End Usage ----------- $rrgr = new RegRename(); Args::PARSE ( $argv, array($rrgr, 'setOption') ); $rrgr->begin();