MP3 Sorting Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
patrick
Forum Newbie
Posts: 2
Joined: Sat Jun 29, 2002 12:22 am
Contact:

MP3 Sorting Script

Post by patrick »

i have a big prob, lol
i have 3100+ mp3s, that are all in one folder.

i have an idea for a sorting script, but im not surehow to pull it off, so instead of me fudging with it, i thot id suggest it and see if anyone else would pick up the task

what this script would do, is scan the directory, group files with the same 7 starting letters for example, then move those files into a folder by the same name. The folders would be made dynamically as files are found...

is it possible?
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

yes, it is... but im not going to write out a script for you, infact it might take several, to do the directory making..and moving the files..etc

some suggestions would be to look into

http://www.php.net/mkdir

http://www.php.net/sort

http://www.php.net/substr

and read alot about arrays.. and how arrays can be used in for and if statements and such....
patrick
Forum Newbie
Posts: 2
Joined: Sat Jun 29, 2002 12:22 am
Contact:

Post by patrick »

i have no problem making it myself
i was unsure if it would be easier to learn or see if anyone knows of anything like this already
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

Code: Select all

$root = "THE DIRECTORY";
$i = "0";
 if ($handle = opendir($root)) {
   while($file = readdir($handle)) {
     if ($file != "." && $file != "..") {
$arrayї'$i'] = "$file";
$i = $i + 1;
     }
   }
   closedir($handle);
 }
if im not mistaken...this should read each filename into an array ($array) in alphabetical order.. might be costly on resources, due to the fact that there are 3,100 or whatever
Post Reply