Help! Creating Folders & Moving Files
I've got roughly 1800 movie files in a folder on the server named like this:
2BTB_061209_Cindy.mp4 2BTB_061211_Mia.mp4 2BTB_061219_Aaliyah.mp4 What I need to do is put them in a folder named the same as their filename, so I'll have: 2BTB_061209_Cindy/2BTB_061209_Cindy.mp4 2BTB_061211_Mia/2BTB_061211_Mia.mp4 2BTB_061219_Aaliyah/2BTB_061219_Aaliyah.mp4 So I copy the file name, create a new folder & name it after the file, then drag the file into the new folder. I can't think of a faster way to do this, but maybe one of you can... |
Try the free version of FiletoFolder. https://www.thecodeline.com/products...-feature-list/
Install it, then close it. Then, when your right click on a file, the context menu should have the FiletoFolder option. It will automatically create a folder of the same name and place the file inside. |
Quote:
|
Shit. I missed that part. It can be done in PHP, but I don't have those sort of skills. (I'm almost strictly a database interaction guy) CD34 could have created a script in 3 and half minutes while eating Arby's.
|
Here is a PHP script to automate it:
Code:
$path = "."; Before: Quote:
After: Quote:
|
OMFG!!!
OK, so I save the code* as greenguy_help.php then upload it to the server and then how do I run it? (I'm not tech savvy lol) Just go to it in a browser? "Execute" it via FTP? *Is there supposed to be a ?> at the end of the code? PS - If this works, Ramster will need your Paypal :D |
Quote:
Talk on Skype, if Skype actually updates you |lol| |
Quote:
|
Quote:
Quote:
|
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. ------------------------------------------------------------------ $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"; } ?> ----------------------- |
If you're scared, change the "mp4" to "jpg" in a folder of test images on your server, then go to the address of this php file in your browser. It won't hurt anything.
Quote:
|
YOU GUYS ROCK!!! |party2
If it was on mine or Ramster's server, I'd run it myself, but like Ramster said, it's a client's server, so we'll have the host do it. |
#pussy :D
|
1 - Worked PERFECTLY! |thumb
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 |
Quote:
PHP Code:
|
Ramster & I |bow| to you!
|
All times are GMT -4. The time now is 04:20 AM. |
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc