#1 : 18/05-23 03:51 Matthew Nelson
Posts: 2
|
Hi,
First, sorry for my lack of knowlege here, the syntax to make this work is a little above my pay grade! I looked at the help and through the forum to try and find a solution, but had no luck. I have a large music collection and have a specific naming format for the mix part of the filename. The 'Mix' name should be in lower case, not affecting the case of the rest of the file. The mix name is always in-between two brackets, BUT there may be other brackets in the filename (such as part of the title) that I don't want affected. Here's an example of what I'm trying to do: Original - Lee Davey-Brown - Ah Yeah (Louis Lennon Remix) {2022}.wav Kohmi - Systems (Extended Mix) {2022}.wav Karl Seery - Move Your Feet (Rocking By Myself) (Original Mix) {2021}.wav Desired Result: Lee Davey-Brown - Ah Yeah (louis lennon remix) {2022}.wav Kohmi - Systems (extended mix) {2022}.wav Karl Seery - Move Your Feet (Rocking By Myself) (original mix) {2021}.wav I tried a few basic regular expressions, and had limited luck (for example .+\( seemed to be giving me the exact OPPOSITE result I needed!) and also tried using the $ expression, but can't figure out how to get it to read backwards. I also tried some exressions to search for items between brackets, but again, was unable to target the LAST bracket set in the name. Any help or a nudge in the right direction would be much appreciated! Thanks! |
#2 : 23/05-23 15:20 Kim Jensen
Administrator
Posts: 906 |
Reply to #1:
Try using the New Case method configured like this: Set pattern to lower case Pattern: \(.*\) Use regular expressions: Checked Apply to: Name |
#3 : 24/05-23 03:28 Matthew Nelson
Posts: 2
|
Reply to #2:
Thank Kim, This works great! Is there anyway to limit the lowercase change to JUST the last set of ( )? Right now it changes both when there are two lots in the file. Example: DJ Traytex - All Good Things (Come To An End) (Club Edit) {2023} Result: DJ Traytex - All Good Things (come to an end) (club edit) {2023} I'm also trying to do a list replace on the last set of ( ) eg items in (club edit) become [club edit] and can use the ) { to replace the ending bracket, but can't figure out how to change the first instance without changing them all. Example: DJ Traytex - All Good Things (Come To An End) (Club Edit) {2023} Result: DJ Traytex - All Good Things [come to an end) [club edit] {2023} Desired Result: Result: DJ Traytex - All Good Things (Come To An End) [club edit] {2023} Thanks! |
#4 : 24/05-23 08:38 Kim Jensen
Administrator
Posts: 906 |
Reply to #3:
You can do it if you change the last ( and ) to [ and ] before changing the case. You can do so by adding two Replace methods before the New Case method configured like this: Text to be replaced: ( Replace with: [ Occurrence: 2nd (this is important) Use regular expressions: Unchecked Apply to: Name Do the same with the second replace method, but replace ( and [ with ) and ]. After that you will have to update the new case pattern to search for [ and ] instead of ( and ). |
#5 : 24/05-23 12:26 Kim Jensen
Administrator
Posts: 906 |
You can also to it with only a single Script method. I asked ChatGPT to give me a script and it came up with this working script (I only had to make one minor change).
function replaceAndLowercase(match, p1, p2, p3, offset, string) { return p1 + "[" + p2.toLowerCase().substring(1, p2.length - 1) + "]" + p3; } var name = item.newBasename; // Regular expression that finds the last pair of parentheses in the filename var re = /^(.*)(\(.+\))([^()]*)$/; var newName = name.replace(re, replaceAndLowercase); return newName; |