INTERACT FORUM
More => Old Versions => JRiver Media Center 28 for Windows => Topic started 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.
-
You can select all the tracks you want to fix, open the Tag editor panel and enter this in the Name tag:
=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!
-
You can select all the tracks you want to fix, open the Tag editor panel and enter this in the Name tag:
=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!
-
Is there a way to quickly see which tracks meet that criteria?
-
You can type this on the Search box to filter all matching files:
[=regex([Name],/#^\d+\.#/,0)]=1
-
You can select all the tracks you want to fix, open the Tag editor panel and enter this in the Name tag:
=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?
-
This works for tracks starting with numbers followed by spaces, dots, dashes, or no separator at all.
=trim(regex([Name],/#^(\d+[.\s\-]*)?(.*)#/,2))
1 Hotel California
1. Hotel California
1 - Hotel California
1Hotel California
-
You could look at the Number(...) expression as well. It was built to handle jobs like this.
-
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.
-
Do we need a new function? Sure could add if people think. NoNumber(...)
-
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.
-
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.
-
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 :)
-
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!
-
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).
-
Next build:
NEW: Added mode 6 to the clean function which removes leading numbers (including spaces, decimals, and commas).
-
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.
-
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.
-
Where is the build. I can't find it.
Beta only. We'll hopefully promote a build in a day or two.
-
Beta only. We'll hopefully promote a build in a day or two.
Dang. Ok. Thanks!
-
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 ?
-
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...
-
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.
-
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).
-
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)
-
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?
-
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?
-
https://wiki.jriver.com/index.php/Expression_Language
About 1/3 of the way down, read "Field Assignment".
-
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
[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:
=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)
=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].
-
Thanks, I'll try it.
"Review then post, not post then review". :), :), :)
-
Nice job with the Regexes guys!
Brian.
-
How do I access this clean mode feature?
Clean() mode 6 is available on MC 28.0.47 and above.
-
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:
-[=regex([name],/#.+?\d\.\s*(.+)#/,1)]=""
Then you can do the cleaning by selecting all filtered tracks and pasting this on the [Name] field:
=regex([name],/#.+?\d\.\s*(.+)#/,1)
-
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.
-
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.
-
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':
[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:
=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.
-
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.
-
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?
-
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".
-
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.
-
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.
-
terrym@tassie, oh that works perfectly! Thanks for the idea!
-
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.
-
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!!
-
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?
-
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!
-
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.
-
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.
-
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.
-
https://xkcd.com/763/
(https://imgs.xkcd.com/comics/workaround.png)
-
Haha!
-
Would you mind pointing me in the direction of the renaming tools in MC27? I think that is what i am looking for
-
Library Tools on our wiki.
-
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.
-
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.
-
This works for tracks starting with numbers followed by spaces, dots, dashes, or no separator at all.
=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?
-
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.
-
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.
-
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.