Hi'
Maybe that will give a different insight into one possible use of XYplorer with MP3s...
• Tagging:
First, to obtain your "[track number] - [track title]", there's not much choice.
- Either you gather them from IDtags, which means tagging the files first (via MP3tag, MediaMonkey, etc.).
- Or if not possible/available, you have to create a script that will "guess" them by parsing the filenames to strip useless data (e.g. "encoded at 240vbr"). Tough job if the naming is not consistent...
So in any case, the best approach is to ensure everything's tagged correctly first.
Note: AFAIK XYplorer processes ID3v2.3 without a problem here.
• Renaming:
- Of course, if you only need to rename one album, it's much easier to do it from your tagging soft.
- But -maybe that's what you were looking after- a script will come in handy if you need to rename songs differently.
e.g. you've exported a playlist from your favorite player, and want to rename each file differently from your "organized" music folders, in this case with the artist name, album, and song title.
---------
Here's a
(quickly rearranged) script I use just for that purpose.
### MP3 Power Renamer ###
Description:
- Rename your MP3s based on their tags, and by choosing a template

- MP3PowerRenamer.png (11.25 KiB) Viewed 4058 times
Important:
- it processes MP3s only (didn't test it with something else)
- MP3s must be tagged (else it won't touch the files)
- the property numbers for IDtags (e.g #10 for "Title") may differ depending on your OS
Notes:
- templates can easily be added or changed
- it renames a whole folder if nothing is selected, or only selected files
- to rename several folders in one go, switch to Branch view and select all files
- files are renamed directly by the script
- but the script copies to the clipboard the full list of new names, so if you'd rather rename and preview the whole by yourself, just comment out/in 2 lines in the script, then run the script which will open "Files | Rename Special | Edit Item Names...", then select all and CTRL+V
(this can't be done via scripting).
- don't forget: in any case, XYplorer's Undo is very efficient!
Last note:
It's working great here, but only tested under WinXP, so your mileage may vary...

I provide it as-is in case it might be useful... but it's not specially optimized and could be largely enhanced (it depends if someone's interested).
Hope this helps,
Flux
---------
Code: Select all
/* ######################## */
/* # MP3 Power Renamer # */
/* ######################## */
/* */
/* by FluxTorpedoe */
/* ________________________ */
/* version 0.3alpha - 2013-07-31 */
/* Use/Modify freely */
"MP3 Power Renamer"
if (get("CountSelected") == 0) { // Process whole folder
$Song_List = folderreport("filesrel", "r", <curpath>, , , "|");
} else {
$Song_List = get("SelectedItemsPathNames", "|"); // Process only selected files
}
set $NewNames;
// ------------------------------------------------------<> Template list (mirror below in "Template Definiton")
$Template_List = <<<#>>>
1: Track - Title<tab 4>06 - Lullaby
2: Track - Artist - Title<tab 3>06 - The Cure - Lullaby
3: Artist - Title<tab 4>The Cure - Lullaby
4: Artist - Title [Album]<tab 3>The Cure - Lullaby [Disintegration]
5: Artist - [Album] Track - Title<tab 2>The Cure - [Disintegration] 06 - Lullaby
6: Artist - (Year) [Album] - Track Title<tab 2>The Cure - (1989) [Disintegration] - 06 Lullaby
#>>>;
// ------------------------------------------------------<> Template selection
$Template = inputselect("Select an MP3 renaming template<crlf 2><tab>Template<tab 5>Example", trim($Template_List, "<crlf><tab>"), "<crlf>", 0, , , , "MP3 PowerRenamer");
$Template = "$Template_".gettoken($Template, "1", ":");
// ------------------------------------------------------------------------->>> Analyze each file
foreach($song, $Song_List, "|") {
if (getpathcomponent($song, "ext") == "mp3") {
$Song_FileName = getpathcomponent($song, base);
// ------------------------------------------------------<> MP3 Tags - !!! CHECK VALIDITY of # !!!
$Song_Title = property("#10", $song); // Title
$Song_Artist = property("#16", $song); // Artist
$Song_Album = property("#17", $song); // Album
$Song_Year = property("#18", $song); // Year
$Song_Number = property("#19", $song); // Track
$Song_Number = (strlen($Song_Number) == 1)? "0$Song_Number" : $Song_Number; // Add track leading zero
$Song_Genre = property("#20", $song); // Genre
// ------------------------------------------------------<> Template Definition
$Template_1 = "$Song_Number - $Song_Title";
$Template_2 = "$Song_Number - $Song_Artist - $Song_Title";
$Template_3 = "$Song_Artist - $Song_Title";
$Template_4 = "$Song_Artist - $Song_Title [$Song_Album]";
$Template_5 = "$Song_Artist - [$Song_Album] $Song_Number - $Song_Title";
$Template_6 = "$Song_Artist - ($Song_Year) [$Song_Album] - $Song_Number $Song_Title";
// ------------------------------------------------------<> If metadata exists
if $Song_Title {
$NewName = eval($Template);
$NewName = replacelist(regexreplace($NewName, "\s?(:|\?(?=.+))", ","), '*`\`/`|`<`>`?`"', "_`,`,`,````", "`"); // Filename compliant
$NewName = regexreplace($NewName, "(\(\s*\)|\[\s*\]|\{\s*\}|-\s*-)", " "); // Clean empty fields
$NewName = regexreplace($NewName, "-\s*-", "-"); // Clean empty fields
$NewName = trim(regexreplace($NewName, "\s+", " "), " -"); // Clean remaining extra spaces and dash
// Rename files directly - Note: Remove if using the "Edit Item Names..." below
renameitem($NewName, $song, 1);
$NewNames = "$NewNames$NewName.mp3<crlf>";
$i++;
// ------------------------------------------------------<> If metadata missing
} else {
// Work In Progress...
}
}
}
// -------------------------------------------------------------------------<<<
copytext $NewNames; // Copy new names
// Invoke dialog "Edit Item Names..." => userinput: select all and paste
// #147;
if ($i > 0) {
#485; // Refresh list
status($i." song(s) renamed");
} else {
status("No tagged MP3 songs found to rename", "883333", stop);
}
[/size]