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

Language PHP Lines 28
MD5 Hash 494ae5d0b8f3742eedee0f166a7e65a6 Estimated Cost $444 (why?)
Repository https://bitbucket.org/pandaos/kaltura.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php

$directories = glob ( dirname(__FILE__) ."/*" , GLOB_ONLYDIR  );

foreach ( $directories as $dir )
{
echo "[$dir]\n";	
	$files = glob ( $dir ."/*" , GLOB_MARK );
	foreach ( $files as $file )
	{
//		echo "[$file]\n";
		$new_file = strtolower ( $file );
		$new_file = str_replace ( "combined" , "" , $new_file );
		$new_file = preg_replace ( "/[ -]/" , "_" , $new_file );
		$new_file = str_replace ( "___" , "_" , $new_file );
		$new_file = str_replace ( "__" , "_" , $new_file );
		$new_file = str_replace ( "_." , "." , $new_file );
//		$new_file = preg_replace ( "/[_]{2-5}*/" , "_" , $new_file ); // remove double '_' characters
		
		if ( $new_file != $file )
		{
//			echo "Reanming [$file]\n$new_file\n";
			echo "$new_file\n";
			rename( $file , $new_file );
		}
	}
}
?>
Back to Top