INTERACT FORUM

More => Old Versions => JRiver Media Center 28 for Windows => Topic started by: nathanchavez on July 27, 2021, 12:47:33 pm

Title: Remove Numbers from name
Post by: nathanchavez on July 27, 2021, 12:47:33 pm
I need a little help here.  I have a lot of audio tracks where the track number is repeated in the tracks name (the name field, not the file name).  The first image below is the an example of what I want to fix, to make it look more like the second image.  Is there a way I can remove numbers from the name field using the find and replace command?  I'm not sure what to use for the number variable there.
Title: Re: Remove Numbers from name
Post by: zybex on July 27, 2021, 12:56:25 pm
You can select all the tracks you want to fix, open the Tag editor panel and enter this in the Name tag:
Code: [Select]
=trim(regex([Name],/#^(\d+\.)?(.*)#/,2))
This fixes all names starting by a number followed by a dot.
Make a library backup before you do this!
Title: Re: Remove Numbers from name
Post by: nathanchavez on July 27, 2021, 01:32:18 pm
You can select all the tracks you want to fix, open the Tag editor panel and enter this in the Name tag:
Code: [Select]
=trim(regex([Name],/#^(\d+\.)(.*)#/,2))
This fixes all names starting by a number followed by a dot.
Make a library backup before you do this!

Wow!!!  This works perfectly.  Thank you!
Title: Re: Remove Numbers from name
Post by: nathanchavez on July 31, 2021, 05:29:40 pm
Is there a way to quickly see which tracks meet that criteria?
Title: Re: Remove Numbers from name
Post by: zybex on August 02, 2021, 05:43:23 am
You can type this on the Search box to filter all matching files:

Code: [Select]
[=regex([Name],/#^\d+\.#/,0)]=1
Title: Re: Remove Numbers from name
Post by: kr4 on August 02, 2021, 09:45:48 am
You can select all the tracks you want to fix, open the Tag editor panel and enter this in the Name tag:
Code: [Select]
=trim(regex([Name],/#^(\d+\.)?(.*)#/,2))
This fixes all names starting by a number followed by a dot.
Make a library backup before you do this!
Is there something similar for those that do not have the dot?
Title: Re: Remove Numbers from name
Post by: zybex on August 02, 2021, 10:15:16 am
This works for tracks starting with numbers followed by spaces, dots, dashes, or no separator at all.
Code: [Select]
=trim(regex([Name],/#^(\d+[.\s\-]*)?(.*)#/,2))
1 Hotel California
1. Hotel California
1 - Hotel California
1Hotel California
Title: Re: Remove Numbers from name
Post by: Matt on August 02, 2021, 10:35:11 am
You could look at the Number(...) expression as well.  It was built to handle jobs like this.
Title: Re: Remove Numbers from name
Post by: zybex on August 02, 2021, 10:47:05 am
But Number() returns just the number, even if it's in the middle of a string. Here we want to return everything except the number at the beginning of a string.
Title: Re: Remove Numbers from name
Post by: Matt on August 02, 2021, 10:53:24 am
Do we need a new function?  Sure could add if people think.  NoNumber(...)
Title: Re: Remove Numbers from name
Post by: zybex on August 02, 2021, 11:56:30 am
It's more like a new mode for Clean(), to remove track numbers from the start of the [Name], as in the Hotel California examples above. It's not to remove numbers from the middle of a string, just the beginning.
Title: Re: Remove Numbers from name
Post by: lepa on August 02, 2021, 01:16:19 pm
Nena - Keine Luftballons  ;D

If filename is correct one can also use F12 Fill Properties from filename
12 Hotel California
[] [Name]

12.Hotel California
[].[Name]

etc.
Title: Re: Remove Numbers from name
Post by: Matt on August 02, 2021, 03:26:18 pm
It's more like a new mode for Clean(), to remove track numbers from the start of the [Name], as in the Hotel California examples above. It's not to remove numbers from the middle of a string, just the beginning.

I'll add this tomorrow.  I love expression goodies :)
Title: Re: Remove Numbers from name
Post by: nathanchavez on August 02, 2021, 03:38:58 pm
I'll add this tomorrow.  I love expression goodies :)

Really?  That would be super helpful!  I've had thousands of tracks that needed to be renamed, and it would be nice to have an e asier way to do that.

Thank you, zybex, you have been really helpful!
Title: Re: Remove Numbers from name
Post by: kr4 on August 02, 2021, 04:10:22 pm
I'll add this tomorrow.  I love expression goodies :)

Thanks.  I get lots of stuff direct from studios and they tend to include track numbers in filenames (and other tags it they have them).
Title: Re: Remove Numbers from name
Post by: Matt on August 03, 2021, 08:29:58 am
Next build:
NEW: Added mode 6 to the clean function which removes leading numbers (including spaces, decimals, and commas).
Title: Re: Remove Numbers from name
Post by: nathanchavez on August 03, 2021, 01:18:06 pm
Next build:
NEW: Added mode 6 to the clean function which removes leading numbers (including spaces, decimals, and commas).

That's awesome, thank you!  I know this will be very useful.
Title: Re: Remove Numbers from name
Post by: nathanchavez on August 04, 2021, 12:32:40 pm
Next build:
NEW: Added mode 6 to the clean function which removes leading numbers (including spaces, decimals, and commas).

Where is the build.  I can't find it.
Title: Re: Remove Numbers from name
Post by: Matt on August 04, 2021, 01:54:38 pm
Where is the build.  I can't find it.

Beta only.  We'll hopefully promote a build in a day or two.
Title: Re: Remove Numbers from name
Post by: nathanchavez on August 04, 2021, 03:09:00 pm
Beta only.  We'll hopefully promote a build in a day or two.

Dang.  Ok.  Thanks!
Title: Re: Remove Numbers from name
Post by: nathanchavez on October 04, 2021, 01:40:13 pm
Is there a way I can make a smart list from this, with notes on how to trim (see post #2)so I don't have to keep looking up this thread every time ?
Title: Re: Remove Numbers from name
Post by: macdonjh on October 06, 2021, 07:46:24 am
It's more like a new mode for Clean(), to remove track numbers from the start of the [Name], as in the Hotel California examples above. It's not to remove numbers from the middle of a string, just the beginning.

Thanks to @zybex and @Matt.  I don't keep track numbers in my [Name] or filenames, either.  This new feature will be helpful: I've been deleting track numbers manually...
Title: Re: Remove Numbers from name
Post by: Richard Martin on October 06, 2021, 04:11:07 pm
Is there a way I can make a smart list from this, with notes on how to trim (see post #2)so I don't have to keep looking up this thread every time ?
You can create the smart list by selecting "custom" in the drop down where you usually select the field in the rule and then pasting in the search expression.
Title: Re: Remove Numbers from name
Post by: nathanchavez on October 07, 2021, 12:50:57 am
I can add the smartlist that will show me which files need to be renamed by adding "[=regex([Name],/#^\d+\.#/,0)]=1" as a custom  element.  But then the issue becomes, where do I put the command that needs to be run on the now displayed results, in this case "=trim(regex([Name],/#^(\d+\.)(.*)#/,2))"?

Edit-

Holy hell!  I just found out that I can edit the upper panel of the smartlist listings, and that it can act as a makeshift notes panel.  How long has this been here?  Neveer mind, don't tell me.  I'll feel stupid(er).
Title: Re: Remove Numbers from name
Post by: zybex on October 07, 2021, 03:17:00 am
You can just open the smartlist, select all files (CTRL+A), and then enter the expression in the [Name] field of the Tag Editor (replacing the "[Varies]" value).
You can then reopen the smartlist - it should be empty as all names are now fixed.

Note that I modified the Regex on my post above (https://yabb.jriver.com/interact/index.php/topic,130173.msg903378.html#msg903378), your version is not ideal.

Also, you can just use Matt's new Clean() mode:
- Smartlist: [=isEqual(Clean([Name],6),[name])]=0
- Cleanup: =Clean([Name],6)
Title: Re: Remove Numbers from name
Post by: nathanchavez on October 07, 2021, 05:16:22 pm
Quote from: zybex

Also, you can just use Matt's new Clean() mode:
- Smartlist: [=isEqual(Clean([Name],6),[name])]=0
- Cleanup: =Clean([Name],6)

How do I access this clean mode feature?
Title: Re: Remove Numbers from name
Post by: macdonjh on October 11, 2021, 03:02:59 pm
As long as we're asking:

I have a few albums with the individual tracks named: [Artist] - [Track]. [Name]

Note, all that is a text string, not an expression.  I'd like to get rid of everything but [Name].  How can I "scrub" the [Artist], "-", [Track] and ".", plus the spaces?
Title: Re: Remove Numbers from name
Post by: JimH on October 11, 2021, 05:59:42 pm
https://wiki.jriver.com/index.php/Expression_Language

About 1/3 of the way down, read "Field Assignment".
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 11, 2021, 08:36:23 pm
Quote
How can I "scrub" the [Artist], "-", [Track] and ".", plus the spaces?

This should work for your example:

Take a library backup first, then create a Smartlist to find all the files you are interested in:
Right click Smartlists in tree, Add Smartlist>Name 'Find Artist - Track prefix' then click Import/Export and paste the following into the Smartlist rules data window
Code: [Select]
[Media Type]=[Audio] [=Regex([name],^/([artist]\s-\s\d+\.\s/),0)]=1
Ok out and review the files in the Smartlist , if OK then select all and paste the following into the Name tag in the Tag window:
Code: [Select]
=Regex([name],^/([artist]\s-\s\d+\.\s/),-1)Replace([Name],[R1],)
EDIT: This is a neater version of the above code, does the same. (Note to self: Review then Post, not Post then Review)
Code: [Select]
=Replace([Name],Regex([name],^/([artist]\s-\s\d+\.\s/),1),)
That should give you 'cleaned' names IF they all conform to the example you quoted: [Artist] - [Track]. [Name].

Title: Re: Remove Numbers from name
Post by: macdonjh on October 11, 2021, 09:40:44 pm
Thanks, I'll try it.

"Review then post, not post then review".  :), :), :)
Title: Re: Remove Numbers from name
Post by: blgentry on October 12, 2021, 11:36:52 am
Nice job with the Regexes guys!

Brian.
Title: Re: Remove Numbers from name
Post by: zybex on October 12, 2021, 03:30:04 pm
How do I access this clean mode feature?

Clean() mode 6 is available on MC 28.0.47 and above.
Title: Re: Remove Numbers from name
Post by: zybex on October 12, 2021, 03:48:37 pm
As long as we're asking:

I have a few albums with the individual tracks named: [Artist] - [Track]. [Name]

Note, all that is a text string, not an expression.  I'd like to get rid of everything but [Name].  How can I "scrub" the [Artist], "-", [Track] and ".", plus the spaces?

If you want a more generic regex that doesn't depend on the [artist], you can try this filter on the search box:
Code: [Select]
-[=regex([name],/#.+?\d\.\s*(.+)#/,1)]=""
Then you can do the cleaning by selecting all filtered tracks and pasting this on the [Name] field:
Code: [Select]
=regex([name],/#.+?\d\.\s*(.+)#/,1)
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 12, 2021, 05:57:06 pm
I did consider a more generic regex for the [Artist] - [Track]. Name issue but found that it generated a lot of 'false positives' mainly on the classical section of my library where it is not uncommon to find something like the following name tag 'Sibelius: Violin Concerto in D minor, op.47 - 1. Allegro moderato' where the number is a movement number rather than a track number.

Nice compact MC regex expression though! Always something to learn from others in the wonderful world of regex.
Title: Re: Remove Numbers from name
Post by: kr4 on October 12, 2021, 06:20:48 pm
How do I access this clean mode feature?

Yes, please.  Some of us have followed this thread with interest but, frankly, do not know how to implement the feature. 

Can someone give use a procedure or a link to one?

Perhaps it can be added to the "Clean File Properties" dropdown menu.
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 12, 2021, 06:38:30 pm
Quote
Can someone give use a procedure or a link to one?

Zybex has shown how to use this in a previous post, but here it is again:

Select a Name tag field in the Tag window for example a Name containing '1 - Brown Sugar'

Paste the following into the name field: =Clean([Name],6) the result will be 'Brown Sugar'

Hope this explains it.


(still reviewing after posting , darn)

To further explain see my post above about creating a Smartlist to find files that need cleaning but in this case paste the following into the 'Smartlist rules data':
Code: [Select]
[Media Type]=[Audio] [=isEqual(Clean([Name],6),[name])]=0
then as above 'Select All' files (ctrl+A) and then in the Tag window Name field paste:
Code: [Select]
=Clean([Name],6)this will then clean all the selected files Name tag.

You could of course be blunt about it, take a Library backup, select all the files in your Library and then apply =Clean([Name],6) to the Name field to clean each and every one of the Name tags in your library.
Title: Re: Remove Numbers from name
Post by: nathanchavez on October 12, 2021, 07:16:32 pm
I mean, not really.  Just this can be done manually, which works perfectly using the methods described in the first four posts, but there's be no mention of how to access clean features which were implemented in MC 28.0.47 and above.  I've asked.  Yes, I know it's there.  Duh.  But how are they accessed?  That still has not been answered.  I'm running MC 28.0.73 and can see no resemblance to that feature other than clean file properties, which does not allow for custom fields.
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 12, 2021, 08:02:09 pm
They are accessed via the MC expression language, the Clean function is part of that of that language.
When a statement entered into a field is prefixed by '=' it tells MC to invoke the expression rather than literally interpret the string.

So if I were to enter in the Name field where I have '1- Brown Sugar' the statement 'Clean([Name], 6)' the result in the Name field  would be 'Clean([Name]), 6)'
IF however I enter '=Clean([Name], 6)' the result is 'Brown Sugar' so why is this?

It is because MC has invoked the expression (because I told it to with '=') and taken the value of the [Name] field '1- Brown Sugar', done Matt's magic on it and returned the answer 'Brown Sugar'.

The Clean function has been part of the MC expression language for some time, Matt has simply added a new mode to this function. This mode is invoked by specifying 6 in the function. Description of Clean function:   Clean(string, mode)

The expression language wiki explains this (but doesn't show Mode 6 because it was only introduced recently) see https://wiki.jriver.com/index.php/String_Manipulation_Functions#Clean (https://wiki.jriver.com/index.php/String_Manipulation_Functions#Clean)

Does this explain how you access it?

Title: Re: Remove Numbers from name
Post by: nathanchavez on October 12, 2021, 08:08:57 pm
They are accessed via the MC expression language, the Clean function is part of that of that language.
When a statement entered into a field is prefixed by '=' it tells MC to invoke the expression rather than literally interpret the string.

So if I were to enter in the Name field where I have '1- Brown Sugar' the statement 'Clean([Name], 6)' the result in the Name field  would be 'Clean([Name]), 6)
IF however I enter '=Clean([Name], 6)' the result is 'Brown Sugar' so why is this?

It is because MC has invoked the expression (because I told it to with '=') and taken the value of the [Name] field '1- Brown Sugar', done Matt's magic on it and returned the answer 'Brown Sugar'.

The Clean function has been part of the MC expression language for some time, Matt has simply added a new mode to this function. This mode is invoked by specifying 6 in the function. Description of Clean function:   Clean(string, mode)

The expression language wiki explains this (but doesn't show Mode 6 because it was only introduced recently) see https://wiki.jriver.com/index.php/String_Manipulation_Functions#Clean (https://wiki.jriver.com/index.php/String_Manipulation_Functions#Clean)

Does this explain how you access it?

Oh, okay.  I guess I has assumed from Matt's post that there was some sort of gui-driven menu-based option.  But based on what you're saying  there's not, and it's not really anything more than using the Name field.  That works for, I just thought there was a gui-drive way to do it similar to "Clean File Properties".
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 12, 2021, 08:35:36 pm
Oh I see, you were thinking it might have been added to the 'Clean file properties' dialog like I have shown in the attached screenshot (the option in italics DOES NOT EXIST!).

Looks like a 'Feature request' try posting in a separate thread maybe the dev's will take up the idea.
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 13, 2021, 01:19:57 am
I got to thinking about this a bit more and wondered if folks were aware that they could fix this issue at Import time by configuring Auto-Import to 'clean' the Name field as it was imported into the library.
So if the 'Smartlist>Select files>Paste function into Name procedure' is performed on the current files in the library and then Auto-import is configured as follows then one would never need to 'clean' the Names again.
To configure Auto-Import:
Tools>Options>Library & Folders>Configure auto-import>Edit watched folder>Apply these tags (optional)>Add>Field=Name Value=Clean([Name], 6).
See also attached screenshot.
Title: Re: Remove Numbers from name
Post by: nathanchavez on October 13, 2021, 10:45:36 am
terrym@tassie, oh that works perfectly!  Thanks for the idea!
Title: Re: Remove Numbers from name
Post by: terrym@tassie on October 13, 2021, 09:29:48 pm
Pleased it worked for you! Should work for kr4's issue with the 'direct from studio files' (#v.jealous) as well.

I use the auto-import quite extensively for 'sorting out' the metadata on downloads I purchase, putting all the expression code there means I don't have to keep looking up expressions and pasting them into library fields (although I do maintain a text file called 'Useful MC expressions').
You can use quite selective 'If else' type statements to do different 'fixups' for particular publishing labels ( I test on the copyright field).
Metadata varies but is usually consistent from a particular label (at least for classical music).
 
I use just one 'Import Folder' on the high speed SSD as this helps with 'Audio analysis' performance, once the import has completed I use the 'Rename/Copy' tool to move the files to their proper 'home' in my library. I would love an 'After import is complete, rename files to this rule' feature to be added to MC as this would complete the automation for my use case.
 
I prefer to let MC do all the work so I can get on with enjoying playback of my library.
Title: Re: Remove Numbers from name
Post by: kr4 on October 14, 2021, 02:33:36 pm
Pleased it worked for you! Should work for kr4's issue with the 'direct from studio files' (#v.jealous) as well.
It does, thank you very much.

OTOH, having it added to the added to the 'Clean file properties' dialog would be ideal!!
Title: Re: Remove Numbers from name
Post by: Matt on October 14, 2021, 03:14:52 pm
OTOH, having it added to the added to the 'Clean file properties' dialog would be ideal!!

So you're looking for adding a checkbox like:
"Remove leading numbers (including spaces, decimals, and commas)"

To the Clean File Properties tool?
Title: Re: Remove Numbers from name
Post by: kr4 on October 14, 2021, 05:53:29 pm
So you're looking for adding a checkbox like:
"Remove leading numbers (including spaces, decimals, and commas)"

To the Clean File Properties tool?
Yes, please!
Title: Re: Remove Numbers from name
Post by: pilotsanon on December 16, 2021, 06:52:57 am
Sorry, I actually have MC 27 not 28.  I did try adjusting and following the instructions you gave though and it didnt work.  It still imported the file with track number in name. 
Title: Re: Remove Numbers from name
Post by: jack wallstreet on December 16, 2021, 07:48:14 am
This is wonderful capability.   For those who don't want to work with smartlists and expressions, a small program "Advanced Renamer" is what I use when I need to make mass changes to filenames.  Yes, that can confuse MC by changing a filename without telling MC (in which case you'll have a file not found), but it is relatively easy to avoid that problem.   My workflow is: load the files to be renamed in Advance Renamer, Mark the files in MC to be ready to delete (but don't delete), Run Advanced Renamer which renames the files.  As soon as AR is done, delete the old files from the MC database (before MC can figure out that the files are gone).  If you have MC set to auto import, the new files will magically appear.  All Done.   If the filename change affects the database properties, the run the MC command "fill properties from filename.  There are several steps, but if you don't want to deal with smartlist commands, it works well.
Title: Re: Remove Numbers from name
Post by: terrym@tassie on December 16, 2021, 04:21:26 pm
Quote
My workflow is: load the files to be renamed in Advance Renamer, Mark the files in MC to be ready to delete (but don't delete), Run Advanced Renamer which renames the files.  As soon as AR is done, delete the old files from the MC database (before MC can figure out that the files are gone).  If you have MC set to auto import, the new files will magically appear.  All Done.   If the filename change affects the database properties, the run the MC command "fill properties from filename.

Well, each to his own, but this seems like a rather convoluted solution that can be (IMHO better) addressed using the renaming tools available in MC28.
Title: Re: Remove Numbers from name
Post by: zybex on December 16, 2021, 04:46:58 pm
https://xkcd.com/763/
(https://imgs.xkcd.com/comics/workaround.png)
Title: Re: Remove Numbers from name
Post by: JimH on December 16, 2021, 05:03:32 pm
Haha!
Title: Re: Remove Numbers from name
Post by: pilotsanon on December 16, 2021, 09:03:35 pm
Would you mind pointing me in the direction of the renaming tools in MC27?  I think that is what i am looking for
Title: Re: Remove Numbers from name
Post by: JimH on December 16, 2021, 10:30:19 pm
Library Tools on our wiki.
Title: Re: Remove Numbers from name
Post by: macdonjh on December 17, 2021, 11:11:38 pm
Would you mind pointing me in the direction of the renaming tools in MC27?  I think that is what i am looking for

I think you may be looking for Tools -> Library Tools -> Rename, Move & Copy. 

As JimH suggests, the Wiki has instructions for using that function.  It's a big help keeping my media files named consistently and organized.
Title: Re: Remove Numbers from name
Post by: pilotsanon on December 19, 2021, 06:28:38 am
I think the Rename, Move, Copy is what I am looking for.  I have been reading over the info in wiki but one thing I am not finding is how I can create a new preset.  I understand what presets do and using the codes given in wiki I think I can figure out how to do what I want.  I just dont know how to create a new preset so I can go to that one each time.
Title: Re: Remove Numbers from name
Post by: pilotsanon on December 19, 2021, 08:54:56 pm
This works for tracks starting with numbers followed by spaces, dots, dashes, or no separator at all.
Code: [Select]
=trim(regex([Name],/#^(\d+[.\s\-]*)?(.*)#/,2))
1 Hotel California
1. Hotel California
1 - Hotel California
1Hotel California


I have MC27, and this trick worked by pasting this code into Name field for tagging.  As an easier and faster method, do you know if I can make this action into a Preset in Rename, Move & Copy?  If so, how do I create a new Preset?
Title: Re: Remove Numbers from name
Post by: terrym@tassie on December 20, 2021, 01:07:54 am
Quote
If so, how do I create a new Preset?

Wiki: https://wiki.jriver.com/index.php/Rename,_Move,_and_Copy_Files#Presets (https://wiki.jriver.com/index.php/Rename,_Move,_and_Copy_Files#Presets)
Hint: Click the 'Preset' button, then Save, then enter a name for your preset.
Title: Re: Remove Numbers from name
Post by: pilotsanon on December 20, 2021, 12:15:02 pm
This is my attempt.  Nothing happened.  Can you see what I am doing wrong?  Do I need the directory even though I am doing a simple filename change or even rules?  Sorry I am still figuring out presets.
Title: Re: Remove Numbers from name
Post by: zybex on December 20, 2021, 01:25:53 pm
Your screenshot is barely readable, please don't resize it.

You're telling MC rename the file to [Name] (with an expression to cleanup the name). This means you need to already have a valid/good value in the Name field for that file... do you? What is the Name that MC shows for this file in the normal view?

You need to first fix the Name for all files you want, then you can use that Name to rename the actual filenames to the same [Name] value.

Regarding Presets, they're just a way of saving whatever settings you have on this dialog so that you can quickly reuse them later. Just enter the settings/expressions/checkboxes you need, then click Preset->Save and give it a name. Next time you want to use those same settings, your saved preset should be available on the "Preset..." button with whatever name you entered for it.