I just tested it and works smoothly.
Vbulletin put two line breaks in when Howling pasted the code into the code thing. Note that the extension part is case sensitive.
------------------------------------------------------------------
<?php
$path = ".";
$extensions = array( "mp4" );
$files = array_diff(scandir($path), array('.', '..'));
foreach ( $files as $file ) {
if ( ! is_file ( $file ) ) continue;
$file_parts = pathinfo( $file );
if ( ! in_array( $file_parts['extension'], $extensions ) ) continue;
if ( ! file_exists( $file_parts['filename'] ) && ! mkdir( $file_parts['filename'] ) ) { echo "Oops! Could not create directory {$file_parts['filename']}\n"; continue; }
$new_loc = $file_parts['filename'] . "/" . $file;
if ( ! file_exists( $new_loc ) && ! rename( $file, $new_loc ) ) { echo "Oops! Could not move {$file} to {$new_loc}\n"; continue; }
echo $file . " moved to {$new_loc} successfully.\n";
}
?>
-----------------------
__________________
Click here to purchase a bridge I'm selling.
|