/********************************************************/
/* Développé par Dorian Ganganelli */
/* && Geoffroy Vigneron */
/********************************************************/
import java.io.*;
public class PlayList{
static boolean CLEAR = false;
protected String dirFile;
protected File[] fileList;
public static long COUNT = 0;
public static int compteur = 0;
public String nouveauFichier;
protected FileWriter fwrite;
public static FileWriter fw;
protected String morceau;
protected String history=null;
boolean debut = false;
public static int TOTAL = 0;
public static char drive = 'c';
public PlayList(String racine){
this.dirFile = racine;
nouveauFichier = dirFile;
this.fileList =lister( new File(dirFile));
afficher(this.fileList);
}
public static void main(String[] args){
drive = args[0].charAt(0);
int tout = 0;
for (int i=0 ; i<args.length;i++){
TOTAL=0;
//CLEAR = true;
if (new File(args[i]).isDirectory())
new PlayList(args[i]);
tout += TOTAL;
/*try{
fw.write(TOTAL +" PlayLists générées dans "+args[i]+"\n");
fw.write("----------------------------------------------------------\n");
if (i==args.length-1){
fw.write("Total PlayLists générées " + tout + "\n\n");
}
fw.close();
}catch(IOException io){}*/System.out.println(compteur);
}
}
public File[] lister(File f){
File[] retour = f.listFiles();
return retour;
}
public void afficher(File[] list){
//CLEAR = false;
for (int i = 0; i < list.length; i++){
debut = i==0;
if (list[i].isDirectory()){
afficher(lister(list[i]));
}else{
this.morceau = list[i].getName();
if (morceau.endsWith(".mp3") || morceau.endsWith(".wma")||morceau.endsWith(".asx")
){
String fic = list[i].getParent()+"\\"+souschaine(list[i]);
String morc=list[i].getParent()+"\\"+morceau;
System.out.println(morc);
ecrire(fic,morc);
history = fic;
}
}
}
COUNT++;
}
public void ecrire(String destination, String titre){
try{
/*fw = new FileWriter(drive+":\\rapport_list.txt",true);
if (debut) {
fw.write(destination + "\n");
System.out.println("Destination : "+destination);
TOTAL++;
}*/
//if ( CLEAR )
// this.fwrite = new FileWriter(destination,true);
//else
this.fwrite = new FileWriter("playlist.m3u",true);
fwrite.write(titre+"\n");
//CLEAR = true;
compteur++;
fwrite.close();
// System.out.println(compteur);
// fw.close();
}catch(IOException io){}
}
public String souschaine (File f){
String resultat = "";
String parent = f.getParent();
String parentParent = f.getParentFile().getParent();
resultat = parent.substring(parentParent.length()+1)+".m3u";
return resultat;
}
}