Quote:
Originally Posted by Greenguy
1 - Worked PERFECTLY!
2 - Is it by any chance easy to go from this:
2BTB_061209_Cindy.mp4
2BTB_061211_Mia.mp4
2BTB_061219_Aaliyah.mp4
To this:
2BTB_061209_Cindy/source/2BTB_061209_Cindy.mp4
2BTB_061211_Mia/source/2BTB_061211_Mia.mp4
2BTB_061219_Aaliyah/source/2BTB_061219_Aaliyah.mp4
|
Sure. Try this:
PHP Code:
<?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; }
if ( ! file_exists( $file_parts['filename'] . "/source" ) && ! mkdir( $file_parts['filename'] . "/source"
) ) { echo "Oops! Could not create directory {$file_parts['filename']}/source\n"; continue; }
$new_loc = $file_parts['filename'] . "/source/" . $file;
if ( ! rename( $file, $new_loc ) ) { echo "Oops! Could not move {$file} to {$new_loc}\n"; continue; }
echo $file . " moved to {$new_loc} successfully.\n";
}
echo "Done\n";