PageRenderTime 83ms CodeModel.GetById 79ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/package/app/app/alpha/apps/kaltura/lib/reports/fixFileNames.php

https://bitbucket.org/pandaos/kaltura
PHP | 28 lines | 11 code | 2 blank | 15 comment | 2 complexity | 494ae5d0b8f3742eedee0f166a7e65a6 MD5 | raw file
 1<?php
 2
 3$directories = glob ( dirname(__FILE__) ."/*" , GLOB_ONLYDIR  );
 4
 5foreach ( $directories as $dir )
 6{
 7echo "[$dir]\n";	
 8	$files = glob ( $dir ."/*" , GLOB_MARK );
 9	foreach ( $files as $file )
10	{
11//		echo "[$file]\n";
12		$new_file = strtolower ( $file );
13		$new_file = str_replace ( "combined" , "" , $new_file );
14		$new_file = preg_replace ( "/[ -]/" , "_" , $new_file );
15		$new_file = str_replace ( "___" , "_" , $new_file );
16		$new_file = str_replace ( "__" , "_" , $new_file );
17		$new_file = str_replace ( "_." , "." , $new_file );
18//		$new_file = preg_replace ( "/[_]{2-5}*/" , "_" , $new_file ); // remove double '_' characters
19		
20		if ( $new_file != $file )
21		{
22//			echo "Reanming [$file]\n$new_file\n";
23			echo "$new_file\n";
24			rename( $file , $new_file );
25		}
26	}
27}
28?>