Greenguy's Board


Go Back   Greenguy's Board > General Business Knowledge
Register FAQ Calendar Today's Posts

 
 
Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 2019-01-10, 05:44 PM   #5
HowlingWulf
Me fail English? That's unpossible!
 
HowlingWulf's Avatar
 
Join Date: Dec 2003
Location: FL
Posts: 1,381
Send a message via ICQ to HowlingWulf
Here is a PHP script to automate it:

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; }

        $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";
}

Before:
Quote:
-bash-4.1$ ll
total 4
-rw-rw-r-- 1 admin www-data 0 Jan 10 17:50 2BTB_061209_Cindy.mp4
-rw-rw-r-- 1 admin www-data 0 Jan 10 17:51 2BTB_061211_Mia.mp4
-rw-rw-r-- 1 admin www-data 0 Jan 10 17:51 2BTB_061219_Aaliyah.mp4
-rw-rw-r-- 1 admin www-data 662 Jan 10 17:49 greenguy_help.php

After:
Quote:
-bash-4.1$ php greenguy_help.php
2BTB_061209_Cindy.mp4 moved to 2BTB_061209_Cindy/2BTB_061209_Cindy.mp4 successfully.
2BTB_061211_Mia.mp4 moved to 2BTB_061211_Mia/2BTB_061211_Mia.mp4 successfully.
2BTB_061219_Aaliyah.mp4 moved to 2BTB_061219_Aaliyah/2BTB_061219_Aaliyah.mp4 successfully.
-bash-4.1$ ll
total 16
drwxrwsr-x+ 2 admin www-data 4096 Jan 10 17:51 2BTB_061209_Cindy
drwxrwsr-x+ 2 admin www-data 4096 Jan 10 17:51 2BTB_061211_Mia
drwxrwsr-x+ 2 admin www-data 4096 Jan 10 17:51 2BTB_061219_Aaliyah
-rw-rw-r-- 1 admin www-data 662 Jan 10 17:49 greenguy_help.php
__________________
WordPress Porn directory theme => Maddos
Create a Porn Tube => Video Pornster
HowlingWulf is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:37 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc