hi,
I've had this glitch with brasero where when I burn mp3 cds brasero burns the files ordered by name and not by album/artist when the file is named in the "01-songname-artist" format. In essence, the actual song order on the cd will be "01-songname-artist", "01-songname-differentartist", "01-songname-thirdartist"..."02-songname-artist", "02-songname-differentartist", "02-songname-thirdartist" and so on and albums that you would want to play consecutively - don't. The solution to this issue was to simply rename the beginning of the file title by adding a prefix composed of aphabetical characters. That way the songs are burned in order of artist/album (as brasero burns according to alphabetical order) i.e. "prefix1-01-songname-artist", "prefix1-02-songname-artist", "prefix1-03-songname-artist"..."prefix2-01-songname-artist", "prefix2-02-songname-artist", "prefix2-03-songname-artist" and so on.
I wrote a script in Java that automates this for you:
Code:
import java.io.Console;
import java.io.File;
import java.io.IOException;
public class FileRename {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) {
if (args.length < 1) {
System.err.println("Error: No directory was chosen.");
System.exit(0);
}
File dir = new File(args[0]);
File[] listFiles = dir.listFiles();
Console c = System.console();
int length = 3;
if (args.length == 2) {
try {
length = Integer.parseInt(args[1]);
} catch (Exception e) {
System.out.println("Invalid length value given. use default? y/n");
String ans = c.readLine();
c.flush();
if (!ans.equals("y")){
System.exit(0);
}
}
}
while (listFiles[0].isDirectory()) {
dir = listFiles[0];
listFiles = dir.listFiles();
}
for (File f : listFiles) {
if (f.getName().endsWith("3")) {
f.renameTo(new File(f.getParent() + "/"
+ dir.getName().substring(0, length) + "_"
+ f.getName()));
}
}
}
}
say, your much needed to be renamed mp3s are in your "/home/<username>/Music/<artist>" directory then all you do is:
Code:
java FileRename "/home/<username>/Music/<artist>"
and your mp3 files are prefixed with the first 3 letters of the <artist>'s folder's name.
I'd appreciate any sort of feedback on this.
Bookmarks