47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
error_reporting ( E_ALL^E_NOTICE ) ;
 | 
						|
require_once dirname( __FILE__ ) . '/astropenguin/package.php';
 | 
						|
 | 
						|
use astropenguin\botanical\RegRename;
 | 
						|
use astropenguin\botanical\Args;
 | 
						|
 | 
						|
 | 
						|
//----------- Usage -----------
 | 
						|
 | 
						|
if ( !$argv[1] ) 
 | 
						|
	die (<<<__USAGE__
 | 
						|
Usage: php {$argv[0]} [options] [-d directory] [-p patterns] [-s "first match" "second" ...] [...args]
 | 
						|
 | 
						|
  -d <paths>	Directories to look over
 | 
						|
  -p <patterns>	Define RegEx patterns
 | 
						|
  -r		Rename file recursively
 | 
						|
  -s <str ...>	Strings that will replace the matches
 | 
						|
 | 
						|
  Optional:
 | 
						|
	-e <patterns>	Exclude defined pattern
 | 
						|
	-l <File>	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();
 | 
						|
 | 
						|
 |