Old 25th January 2002, 22:21   #1
SteveB
Junior Member
 
Join Date: Dec 2001
Posts: 6
Automated M3U creation?

Hi all,

I currently have all my mp3's sorted in a directory structure of Artist name>Album.

I now have the opportunity to run playlists from remote control (which is cool), but need to create a numbered playlist (01 throutgh to 450) for each album I own (450 odd!). As you can imagine, this is a lttle daunting, not to say a boring task!

What I am looking for then, is a shareware app (or plugin) that will automatically create numbered playlists, based upon mp3's stored in unique directorys (as I have).

It's a long shot, but does anyone know how to do this??



SteveB is offline   Reply With Quote
Old 26th January 2002, 01:32   #2
Rocker
Hiding in plain sight (mod)
 
Join Date: Jun 2000
Location: Melbourne, Australia
Posts: 9,910
i think you'll have to do it all manually

when encoding cd's you can make it automated

http://www.cdex.n3.net there's a command for it.....

this is also the best encoder/ripper
Rocker is offline   Reply With Quote
Old 26th January 2002, 01:37   #3
Curi0us_George
Forum King
 
Curi0us_George's Avatar
 
Join Date: Apr 2001
Location: Oxford, MS Posts: -1
Posts: 5,179
Send a message via AIM to Curi0us_George Send a message via Yahoo to Curi0us_George
It wouldn't be a hard application to write, but I don't think anyone has done so yet.

For the freedom to express myself in my own way without fear of being censored or banned.

47 65 6C 61 65 64 2E 63 6F 6D 00
Curi0us_George is offline   Reply With Quote
Old 26th January 2002, 03:47   #4
Curi0us_George
Forum King
 
Curi0us_George's Avatar
 
Join Date: Apr 2001
Location: Oxford, MS Posts: -1
Posts: 5,179
Send a message via AIM to Curi0us_George Send a message via Yahoo to Curi0us_George
Here you go! Custom written by me.

Download the attachment (or compile for yourself if you prefer)

Install the JRE if you haven't already, then open a command prompt,
browse to the folder you download the attachment to, and type in:
"java M3UGen"

(I think you may need to add the JRE "bin" folder to your path,
but it may occur automatically.
Or, you could type in the whole "java.exe" path in the prompt. . . )

A "File Chooser" will pop up.
Just choose the directories and files you want to create M3U files for.
Hit "Save".
Wait a few seconds or minutes
(depending on your collection and how fast your computer is)
and you'll have a list of M3Us, numbered 1 to x.

Done!

(Someone owes me some sexual favors )

Here's the code:
code:

/**
* Copyright Derek Park, 2002
* Gelaed.com
*
* Version 0.9a
*
* Released under the GNU Public License
*/

import java.util.Vector;
import java.io.File;
import java.io.FileOutputStream;
import javax.swing.JFileChooser;

public class M3UGen {
private static Vector recurseSubdirectories(File[] f, String[] exts) throws Exception {
Vector dirList = new Vector(100);
recurseSubdirectories(f,exts,dirList);
return dirList;
}

private static void recurseSubdirectories(File[] f, String[] exts, Vector dirList) throws Exception {
String s;
Vector curDir = new Vector(100);

boolean addedAny = false;
for(int i = 0; i < f.length; i++) {
if(f[i].isDirectory()) {
recurseSubdirectories(f[i].listFiles(),exts, dirList);
} else {
s = f[i].getName();
s = s.substring(s.length() - 3, s.length());
boolean addedCurrent = false;
for(int j = 0; j < exts.length; j++) {
if(s.equalsIgnoreCase(exts[j])) {
addedAny = true;
addedCurrent = true;
System.out.println("Adding " + f[i].getCanonicalPath());
curDir.add(f[i]);
}
}
if (!addedCurrent) {
System.out.println(f[i].getCanonicalPath() + " could not be added");
}
}
}
if(addedAny) {
dirList.add(curDir);
}
return;
}

public static void main(String [] args) {
try {
JFileChooser multiFileChooser = new JFileChooser();
multiFileChooser.setMultiSelectionEnabled(true);
multiFileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
if(multiFileChooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
System.out.println("Copyright 2002 Derek Park - Gelaed.com - Released under the GPL");
System.out.println("M3UGen 0.9a");
System.out.println("\nSimply choose a set of files a directories");
System.out.println("M3UGen will produce numbered M3U playlists");
System.out.println("\nNo files chosen - Exitting");
System.exit(0);
}
File [] f = multiFileChooser.getSelectedFiles();
String loc = f[0].getParent();

Vector v = recurseSubdirectories(f,new String[]{"mp3","ogg","mpc","mp+"});
System.out.println("Directory for output: " + loc);
System.out.println("Number of files to be written: " + v.size());
for (int i = 0; i < v.size(); i++) {
if (!(v.elementAt(i) instanceof Vector)) {
System.out.println("Major error!");
System.out.println("v.elementAt(i):");
System.out.println(v.elementAt(i));
System.out.println("Program aborted.");
System.exit(1);
}
Vector currentVec = (Vector)v.elementAt(i);
//File currentFile = new File(loc + "\\" + String.valueOf(i) + ".m3u");
File currentFile = new File(loc + "\\" + String.valueOf(i + 1) + ".m3u");
System.out.println("Creating new file: " + currentFile.getCanonicalPath());
FileOutputStream fos = new FileOutputStream(currentFile);
for (int j = 0; j < currentVec.size(); j++) {
if (!(currentVec.elementAt(j) instanceof File)) {
System.out.println("Major error!");
System.out.println("currentVec.elementAt(j):");
System.out.println(currentVec.elementAt(j));
System.out.println("Program aborted.");
fos.close();
System.exit(1);
}
String nextLine = ((File)currentVec.elementAt(j)).getCanonicalPath() + "\r\n";
fos.write(nextLine.getBytes());
}
fos.flush();
fos.close();
}
}
catch (Exception e) {
System.out.println("Exception thrown");
e.printStackTrace();
System.exit(1);
}
System.out.println("Copyright 2002 Derek Park - Gelaed.com - Released under the GPL");
System.out.println("M3UGen 0.9a");
System.out.println("Exitting successfully");
System.exit(1);
}
}


For the freedom to express myself in my own way without fear of being censored or banned.

47 65 6C 61 65 64 2E 63 6F 6D 00
Curi0us_George is offline   Reply With Quote
Old 26th January 2002, 03:50   #5
Curi0us_George
Forum King
 
Curi0us_George's Avatar
 
Join Date: Apr 2001
Location: Oxford, MS Posts: -1
Posts: 5,179
Send a message via AIM to Curi0us_George Send a message via Yahoo to Curi0us_George
P.S. This is only meant for Windows. It needs some modification for *nix use.

Here's the attachment, too.

(Damn, I have to zip it. Just unzip it before use.)
Attached Files
File Type: zip 3ugen.zip (3.5 KB, 104 views)

For the freedom to express myself in my own way without fear of being censored or banned.

47 65 6C 61 65 64 2E 63 6F 6D 00
Curi0us_George is offline   Reply With Quote
Old 26th January 2002, 09:18   #6
SteveB
Junior Member
 
Join Date: Dec 2001
Posts: 6
OMG!

That is soo great of you I don't know what to say!
Thanks. I'll write back and let you know how I get on..
SteveB is offline   Reply With Quote
Old 26th January 2002, 10:19   #7
SteveB
Junior Member
 
Join Date: Dec 2001
Posts: 6
Works an absolute treat!

Must have saved me at least a day of sitting here clicking...

Thanks alot - can't believe how generous that was..

SteveB is offline   Reply With Quote
Old 26th January 2002, 15:38   #8
DJ Egg
Techorator
Winamp & Shoutcast Team
 
Join Date: Jun 2000
Posts: 35,894
Woahhh! Top job C_G

I'll definitely add a link to this thread in TSGH -> Useful Links.

Most ingenious . . . . muchos kudos
DJ Egg is offline   Reply With Quote
Old 26th January 2002, 17:55   #9
Curi0us_George
Forum King
 
Curi0us_George's Avatar
 
Join Date: Apr 2001
Location: Oxford, MS Posts: -1
Posts: 5,179
Send a message via AIM to Curi0us_George Send a message via Yahoo to Curi0us_George
Aww, shucks.
/me looks down and kicks the sand a bit
'Tweren't nothin'

You're welcome. It didn't really take that long, and I'm planning to reuse the functionality in JTagger sometime soon.

It's going to be useful for me, too. I've already used a modified version (m3u names generated by directory names, instead of numbers) to make playlists for most of my collection.

Whenever I start working on JTagger again, I'll add this in, in some form or another.

For the freedom to express myself in my own way without fear of being censored or banned.

47 65 6C 61 65 64 2E 63 6F 6D 00
Curi0us_George is offline   Reply With Quote
Old 28th January 2002, 02:21   #10
Sonicide
Junior Member
 
Join Date: Dec 2001
Location: Australia
Posts: 23
I know several ppl have said it already, but nice work cg!
One question though, why did you use System.exit(1)
right at the bottom after printing "Exiting successfully"?
If you really are exiting successfully shouldn't it be System.exit(0)?
Sonicide is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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