Renaming MP3s

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
oblivion
Posts: 149
Joined: 13 Apr 2011 11:35

Renaming MP3s

Post by oblivion »

I need to do some major sorting out of my MP3 library -- in particular, I want to make a button that will rename *.mp3 in the current folder to a filename structure like [track number] - [track title].mp3 AND I want the track number to have an appropriate number of leading zeroes -- usually padded to a 2-digit number, I think.

(Actually, although most of my music is MP3 I have a scattering of other formats too, so I guess the rename should select *.mp3|*.m4u|*.whatever and leave the extension intact.)

Also, I'd like to be able to see at a glance if I'm going to hit a problem before executing the rename, so can I set a sort to tracknumber, ascending while I'm working through all these files and folders?

Am I asking for miracles? ;)
-- bests, Tim

...This space unintentionally left blank.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Renaming MP3s

Post by TheQwerty »

It's been a few years since I took the time and care to manage my music files, but back then my go to program for all things tag based was: http://www.mp3tag.de/en/

I'm not sure if you can get it down to just a single button in XY calls MP3Tag and performs the renaming/moving, but I think it should be possible to have XY open MP3Tag and then have a single button in MP3Tag execute your orders.

HTH

oblivion
Posts: 149
Joined: 13 Apr 2011 11:35

Re: Renaming MP3s

Post by oblivion »

TheQwerty wrote:It's been a few years since I took the time and care to manage my music files, but back then my go to program for all things tag based was: http://www.mp3tag.de/en/
Not sure that was the answer I was expecting :)

If I'm going to use an external application for this, it'll be MediaMonkey, which I already own a license for. But it feels like using a sledgehammer to crack a walnut!

I had assumed that if I could use the "MP3 special" renaming functions for various pre-rolled renaming functions, if I dug a little deeper I'd be able to haul out the properties of an MP3 and use those properties to rename based on my own wishes, and make a button for fast access.

What's the "I can't do this in XY" bit? Any of it? Just the display of the track number in the file list? Just the "pad the track number to 2 digits" bit?
-- bests, Tim

...This space unintentionally left blank.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Renaming MP3s

Post by TheQwerty »

I've never trusted Windows' metadata with regards to music files other than for formats I wouldn't use (WMA, etc.), so I'd personally never trust what it returns with Property.

Also last I checked XY's tag support was limited to only ID3 and didn't work with ID3v2.4 - in fact I think Don may only claim to support ID3v1.1.

Between those two "issues" I've always felt it was better to use a proper tool for music management rather than XY.
oblivion wrote:If I'm going to use an external application for this, it'll be MediaMonkey, which I already own a license for. But it feels like using a sledgehammer to crack a walnut!
Hence why I took to using MP3tag. It was (hopefully still is) free, light-weight, and focused on doing only one thing extremely well.


Sorry I can't be of much help in using only XY to accomplish this - good luck!

oblivion
Posts: 149
Joined: 13 Apr 2011 11:35

Re: Renaming MP3s

Post by oblivion »

TheQwerty wrote:I've never trusted Windows' metadata with regards to music files other than for formats I wouldn't use (WMA, etc.), so I'd personally never trust what it returns with Property.

Also last I checked XY's tag support was limited to only ID3 and didn't work with ID3v2.4 - in fact I think Don may only claim to support ID3v1.1.
Oh, I see. That makes sense -- and perhaps explains some of the difficulties I’ve had finding the data. Thanks for the clarification!
Hence why I took to using MP3tag. It was (hopefully still is) free, light-weight, and focused on doing only one thing extremely well.
There’s a lot to be said for that. :)

I’m very good at stuffing things up with MediaMonkey -- the auto-tag from Amazon functionality’s very cool but sometimes the default result returned is, erm, less than optimal and if I’m not paying attention properly... so I thought I could find another, faster, more stripped-down way to handle just this process and naturally XY came to mind -- but I’ll investigate MP3tag and see if I can make it do what I want. Thanks!
-- bests, Tim

...This space unintentionally left blank.

FluxTorpedoe
Posts: 896
Joined: 05 Oct 2011 13:15

Re: Renaming MP3s

Post by FluxTorpedoe »

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
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, 8)
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]

oblivion
Posts: 149
Joined: 13 Apr 2011 11:35

Re: Renaming MP3s

Post by oblivion »

FluxTorpedoe wrote:Hi'

So in any case, the best approach is to ensure everything's tagged correctly first.
In my case, I'm reasonably confident of it. I always try to ensure stuff's properly tagged simply because MediaMonkey and my MP3 players pay a lot more attention to tags than filenames. It's one of the reasons my filenames are all over the place, because over the years I've used all sorts of naming strategies. And generally I've never worried about having the track number in the filename because my MP3 players read it from the tag. Sometimes I've even deliberately renamed things that DID have the track number in the filename just so it looked better in a file list.

The main problem I'm trying to resolve is a direct result of the fact that my wife's MP3 player has the facility for an expansion SDHC card BUT the contents of that card don't get added to the player's library. So the only way to get albums to play in track order if they're being played from the card is to ensure that an alphabetic sort by filename is the equivalent of a track number sort by tag. And having decided on a strategy, I want to use it across my whole collection, just for tidiness, and because, who knows, my wife might suddenly develop a taste for something it never occurred to me she might like. :)
Of course, if you only need to rename one album, it's much easier to do it from your tagging soft.
Nope. Lots of albums. Hundreds. (I have a 40Gb MP3 player and it doesn't hold all the music I have. I also have many CDs I have yet to get around to ripping.)

I'm comfortable working through them one at a time -- I don't want to find out in a fortnight that I've broken something by accident, through making a few unwarranted assumptions -- but a single button rename to the naming strategy I want is a LOT easier than, well, anything more complicated. :)
Here's a (quickly rearranged) script I use just for that purpose.
I'll give it a try -- many thanks!
It's working great here, but only tested under WinXP, so your mileage may vary... ;)
I can't imagine it'll be very different under Vista or 7 but I'll test carefully :)
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).
I'm more likely to strip it back so it doesn't ask me anything, but my first step's going to be understanding what you've done and how you've done it so I can avoid stripping anything out I actually need :)

Thanks again -- it looks brilliant!
-- bests, Tim

...This space unintentionally left blank.

FluxTorpedoe
Posts: 896
Joined: 05 Oct 2011 13:15

Re: Renaming MP3s

Post by FluxTorpedoe »

Well, with a well-tagged library, a script will sure do wonders! 8)

If you have any question about mine, don't hesitate, since it was mainly an "internal" release...

& any feedback on your own use under Win7 could be helpful. :)

GUIguy
Posts: 115
Joined: 03 Jan 2016 02:11
Location: Oregon, USA Win 10-64
Contact:

Re: Renaming MP3s

Post by GUIguy »

I came across this thread because I was looking for the same thing. With my limited experience and knowledge, simplicity is paramount.

Well, MP3Tag does EXACTLY what I--and I think several others--are looking for. In particular, the page https://docs.mp3tag.de/converters/rearrange-filenames/ explains it clearly.

It has solved my problem.

However, since this thread is quite old, perhaps it's possible in XY now. If so, I'd appreciate knowing where and how.
GUIguy
I measure a good day by how little I fell behind

Quick, hire a teenager while they still know everything!

highend
Posts: 14243
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Renaming MP3s

Post by highend »

Configuration | General | Menus, Mouse, Usability | Context Menus | File List...
[x] Rename Special

context menu - rename special - mp3 special - ...

if the variants there don't suit you, use scripting...
One of my scripts helped you out? Please donate via Paypal

GUIguy
Posts: 115
Joined: 03 Jan 2016 02:11
Location: Oregon, USA Win 10-64
Contact:

Re: Renaming MP3s

Post by GUIguy »

Thanks, HighEnd...

After finding it in the menu, I also checked the help file and it said "The factory default presets can be altered by editing the INI file."

However, in searching through the ini file, I could not find where to make the changes.

Color me stupid, but can you point me in the right direction? (Actually, MP3Tag does this easily, but I'm now challenged because it's my firm belief that XY can do ANYTHING with a file! Sorry, Don, that's your fault!!! :lol: :appl: :appl: )
GUIguy
I measure a good day by how little I fell behind

Quick, hire a teenager while they still know everything!

highend
Posts: 14243
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Renaming MP3s

Post by highend »

One of my scripts helped you out? Please donate via Paypal

GUIguy
Posts: 115
Joined: 03 Jan 2016 02:11
Location: Oregon, USA Win 10-64
Contact:

Re: Renaming MP3s

Post by GUIguy »

BINGO!

Even I was able to figure it out. (Still your fault, Don! :lol: :appl: )
GUIguy
I measure a good day by how little I fell behind

Quick, hire a teenager while they still know everything!

Post Reply