Delete a variable text string in File Name

Bulk Rename Utility How-To's

Delete a variable text string in File Name

Postby dec » Thu Aug 31, 2023 7:43 am

There is so much posted here in varying degrees of clarity & explicitness, that i can not be sure if this question/issue is answered somewhere; however, this question & issue would become redundant if BRU Replace function was fixed/enhanced slightly

so.

basically i want to delete a number of characters (that vary) by defining their position from the END of the file name

Indeed with almost every app, the file name has a highly variable content and length, so that defining a string position from the start of a file name can often be problematic, eg music track names as in this case.

and simply Replace does NOT have any capacity to define a position from the END of a file name

frustratingly, the ADD functions DOES have such an option, albeit a bit kludgy - the From parameters WILL take a NEGATIVE value - which can be used to select a position from the end: the Replace function does NOT have this possibility.

so in this case, i can C&P one example ...

Anneke Van Giersbergen - Time After Time [La Scene Bastille] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192] [norm-aimp-0db] [619 min].flac

so in the above name, i want to delete a redundant and old data about the encoding (as should be indicated in bold). if that data/text string was always the same, no problem of course - but it isn't. :-(

(and i cannot rebuild the name from scratch as the same old data is in the Title field too.)

so any brilliant ideas, anyone?
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby dec » Thu Aug 31, 2023 8:24 am

PS I had theh notion of just deleting ALL the text from the end up to the basic file name and then rebuilding with teh current data/fields - doesn't work. the length of the text from the end is too variable. which possibly makes ANY solution problematic. maybe if i try 'batching' files with the same data/values in the File Name (and hence the same length from the end)?
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Delete 1st 3-groups of [text] from 7-groups at the end

Postby Luuk » Thu Aug 31, 2023 10:35 am

With RegEx(1) having a checkmark for "v2", the "Match" can be like...
( \[[^]]+\]){3}(?=( \[[^]]+\]){4}$)
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Delete a variable text string in File Name

Postby dec » Thu Aug 31, 2023 1:53 pm

PPS i thoughty of heading over to MP3Tag to use their Convert or Ac tion nscripts, but i still can't work out how to that either
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby dec » Fri Sep 01, 2023 4:13 am

apart from the fact that i don't really understand the RegEx, the 'fatal' problem seems to be that my (music track) File Names are just too variable and complex to use most formulae.

The best single most common factor/text i can find is to delete this string ... [norm91] [????min] ...

(i have deliberately held off global deleting '[norm91]' so i can use it to link to the (duplicated) duration/length data that comes immediately after.)

so i 'just' need a RegEx that searches for '[norm91]' in File Name and adds the next 10 characters after that and deletes them.
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby therube » Fri Sep 01, 2023 7:19 pm

If all you want to do is to truncate everything after (the final instance of) '[norm', then:

1:RegEx
Code: Select all
Match:  (.*)(\s\[norm)
Replace:  \1

find anything (up to)
find <space>[norm (& ignore it & all the follows)

keep the first part, ignore all else.


Code: Select all
Anneke Van Giersbergen - Time After Time [La Scene Bastille] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192] [norm-aimp-0db] [619 min].flac

->   Anneke Van Giersbergen - Time After Time [La Scene Bastille] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192].flac

Code: Select all
Anneke Van Giersbergen - Time After Time [norman lear version] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192] [norm91] [619 min].flac

->   Anneke Van Giersbergen - Time After Time [norman lear version] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192].flac
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Delete a variable text string in File Name

Postby dec » Sun Sep 03, 2023 8:00 am

sorry. i am NOT getting Notifications for some reason.

i still don't understand RegEx - just too cryptic for me)

but i understand the method/logic

so one way, maybe easiest way, might be to do a global radical trunc of all affected file names (a lot), and then rebuild/readd the required bits, eg Bit Rate, Duration, again in MP3Tag
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete 1st 3-groups of [text] from 7-groups at the end

Postby dec » Sun Sep 03, 2023 8:02 am

Luuk wrote:With RegEx(1) having a checkmark for "v2", the "Match" can be like...
( \[[^]]+\]){3}(?=( \[[^]]+\]){4}$)


that won't work because of variable no of words/groups/fields from the start of file name eg some files/tracks might have an album name or a concert name, and some tracks won't
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Delete 1st-3 [strings] from ending-7 [strings]

Postby Luuk » Sun Sep 03, 2023 10:16 am

The regex conducts your description to match [strings] at 'their position from the END of filenames'.
So just like the example was asking, it removes the 1st-3 [strings] from those ending-7 [strings].
But if your filenames is not like the example, then of course should not be used for renaming.

This another 'v2' match, but still without knowing your filename-formats (besides the 1-example)...
\x20\[\d+[^]]*k?Hz\] \[conv-\d+[^]]*\] \[\d+ min\](?= \[\d+[^]]*k?Hz\] \[conv-\d+[^]]*\]( \[norm[^]]+\])? \[\d+ min\]$)

Its like the 1st-one, but the ending 6-or-7 [strings] must be like... [.*Hz] [conv.*] [.*min] [.*Hz] [conv.*] [norm.*] [.*min].
Like the 1st-one, it removes the 1st-3 [strings] from the ending 6-or-7 [strings], with the [norm.*] string being optional.
If all of the filenames will always have the [norm.*] string, then its better to just remove the "?" after that string.

There is many other ways, but they all depend on your filename-formats, so really I'm not going to keep guessing.
Only you can see them, and if not wanting to post now-names-->new-names, its a guessing game to everyone else.
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Delete a variable text string in File Name

Postby dec » Sun Sep 03, 2023 8:03 pm

therube wrote:If all you want to do is to truncate everything after (the final instance of) '[norm', then:

1:RegEx
Code: Select all
Match:  (.*)(\s\[norm)
Replace:  \1

find anything (up to)
find <space>[norm (& ignore it & all the follows)

keep the first part, ignore all else.


Code: Select all
Anneke Van Giersbergen - Time After Time [La Scene Bastille] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192] [norm-aimp-0db] [619 min].flac

->   Anneke Van Giersbergen - Time After Time [La Scene Bastille] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192].flac

Code: Select all
Anneke Van Giersbergen - Time After Time [norman lear version] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192] [norm91] [619 min].flac

->   Anneke Van Giersbergen - Time After Time [norman lear version] [2012] [136kbits 48kHz] [conv-96kHz] [619 min] [868 kbps 96 kHz] [conv-192].flac


thanks.
first time works exactly. :-)
and then modified for another string and worked also

but this string it just ignores

(.*) (\s\ [2)

and i can't figure out why it is any different.

4th Power - Bang Bang [The X Factor UK 2015] [2015] [276kbits] [08-12min].m4a
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby therube » Tue Sep 05, 2023 4:59 pm

(.*) (\s\ [2)

\s represents a <space>
& "\ " (& " " for that matter) also represents a <space>.

So you are searching for "<space><space>[2", which does not exist.

So just change it to, (.*)(\s[2).
(Find anything, up to <space>[2.)
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Delete a variable text string in File Name

Postby dec » Thu Sep 07, 2023 9:25 am

ahhh.

Thanks
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby dec » Thu Sep 07, 2023 9:27 am

therube wrote:
(.*) (\s\ [2)

\s represents a <space>
& "\ " (& " " for that matter) also represents a <space>.

So you are searching for "<space><space>[2", which does not exist.

So just change it to, (.*)(\s[2).
(Find anything, up to <space>[2.)


but your example had it seems... \s\space[norm) ?
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby dec » Thu Sep 07, 2023 9:35 am

ok.

so what is Regex if we want to locate a unique text string, and then delete n no of characters after it?

this is basically because of a 'bug' in BRU where the Add module can take a NEGATIVE value (much to my surprise) - and therefore works from the end which is very very useful/essential; BUT the Remove module DOES NOT HAVE THE SAME FUNCTIONALITY

so my idea is that i will use the Add function using the negative value from the end of name to add a unique string eg 'xxx' at the start of the string to remove, and then use Regex to find that unique string, and remove n characters after it (something like [norm91] [192kbits 48mHz] which are old redundant values)
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Re: Delete a variable text string in File Name

Postby dec » Thu Sep 07, 2023 10:02 am

dec wrote:ok.

so what is Regex if we want to locate a unique text string, and then delete n no of characters after it?

this is basically because of a 'bug' in BRU where the Add module can take a NEGATIVE value (much to my surprise) - and therefore works from the end which is very very useful/essential; BUT the Remove module DOES NOT HAVE THE SAME FUNCTIONALITY

so my idea is that i will use the Add function using the negative value from the end of name to add a unique string eg 'xxx' at the start of the string to remove, and then use Regex to find that unique string, and remove n characters after it (something like [norm91] [192kbits 48mHz] which are old redundant values)


oh. here is a CORRECT name
Van Morrison - Sweet Thing [2010] [conv-192] [norm-aimp-0db] [256 kbps 48 kHz] [04_26min]

and here is one to fix ...
Alma Cogan - Twenty Tiny Fingers [norm91] [192 kbps 44 kHz] [conv-192-48kHz] [norm-aimp-0db] [239 min]

that is not an exact example but you get the idea
dec
 
Posts: 67
Joined: Thu Oct 14, 2021 6:31 am

Next

Return to How-To