Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: foobar2000 mass rename xx year in file name to xxxx (Read 5956 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

foobar2000 mass rename xx year in file name to xxxx

I have a 50+ CD collection that has the issue of the dates being in dd-mm-yy instead of dd-mm-yyyy. So the file name would be "01. Get Back (01-12-02)" and the title would be "Get Back (01-12-02)" (This distinction being particularly important so that any renaming does not end up in my losing my title track order.)

How do I get it to be "Get Back (01-12-2002)"

(Of course tracks exist for the last milennium too.)

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #1
Through complex string formatting scripts that are highly prone to breakage.

Or through manually retagging your entire collection to use four digit years in the filenames.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #2
Even if I use <track no>. <title> for mass rename?

Is the issue the difference between title and file name or inherent to the naming system?

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #3
Hmm, Bulk Rename Utility might be a better choice, actually. Assuming you want to preserve those date suffixes and they're not in the tags. If they're in the tags, you can probably try to assume whatever syntax is in your tags, and use a conditional check on the year range of the string. Probably safe to assume anything 22 or higher is 19xx, while 00-21 will be 20xx.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #4
The title tag does indeed have the dates. Is there no mass command to add '20' if the value range is between '-00' to '17'?

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #5
You'll need the masstagger component, and you'll need to process a few things:

1) Select all affected files.
2) Open Tagging -> Manage scripts.
3) Add the step "Guess value from other fields".
4) Configure it so that source format is "%title%", assuming your title tag is where the mess lives.
5) Configure the Guessing pattern to match your title format. It should probably be something like "%newtitle% (%date%)" - This is a big note. If your %title% tag contains tracknumbers as well, you'll want: "%tracknumber%. %newtitle% (%date%)"

At this point, you've got a script which derives a title tag without a date in it, and derives the date tag, and also a tracknumber if that's relevant to the format your title tags use.

Now, you should add a step:
1) Add Format value from other fields.
2) Set destination field name to "DATE"
3) Set format to:
Code: [Select]
$substr(%date%,1,6)-$puts(y,$substr(%date%,8,9))$ifgreater($get(y),21,19,20)$get(y)

This step should format your %date% tag so it has a four digit year, and the ifgreater condition checks if the year is greater than 21, emitting 1922-1999, else emitting 2000-2021. Change the 21 to the most recent year you're likely to have tagged.

Once you're satisfied with your date tags, you can go ahead and format the "TITLE" tag from "%newtitle%", or possibly "%newtitle% '('%date%')'" or possibly even "%tracknumber%. %newtitle% '('%date%')'", then delete the "NEWTITLE" field. These can both be done as steps with the masstagger as well.


Re: foobar2000 mass rename xx year in file name to xxxx

Reply #7
Your file data is too complex to process automatically. You'll need to do it all manually.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #8
Your file data is too complex to process automatically. You'll need to do it all manually.

I had another idea. All the live performances file names end in "-xx]"

Is that something syntax could be used for to make it to "-19xx]"?

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #9
The title tag does indeed have the dates. Is there no mass command to add '20' if the value range is between '-00' to '17'?
You got like fifty CDs? That isn't much. Problem is if you are constantly getting new bootlegs in that old format. Then you need to be able to search up those which fit that pattern and ...

But if you only need to do it once, you can search up tracks for *-0?) OR *-1?) OR *-2?) and that will return everything that ends in -00) through -29) to get the 20 in front. You need to escape the parenthesis though. And if you have a mix of round parentheses and brackets, consider *??-??-0?? OR *??-??-1?? OR *??-??-2?? and see if that returns any false positives.
And then do similar to get the 19.

But, it is possible to code the 19 vs 20 in fb2k without IFs by using the fact that fb2k division rounds down to integer. $div(x,$max(x,22)) will return 0 if x is 0 through 21, and 1 if x is 22 or more. Subtract that from 20 to get 20 or 19 as appropriate.

What I would have done, is
* Split the track title between the first N-11 characters (to go into title) and the 8 running from N-9 to N-1 (to go into a new trackdateddmmyy tag).
* Fix the trackdateddmmyy tag into trackdate
* Apply a renaming that does not use "(" nor ")" for the dates, as parentheses are too commonly found in track titles. You can for example use a character like µ (the micron) or ¨; or if you insist on ASCII printable (non-"extended") I have no ` in metadata in my collection, and if you are equally lucky that character will uniquely be a separator. Say, 01. Get Back `01-12-2002.
... well of course you should use the useful date format for 01. Get Back `2002-12-01

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #10
I had another idea. All the live performances file names end in "-xx]"
Is that something syntax could be used for to make it to "-19xx]"?
You only want to change the filenames?

Select the tracks that end in "-xx]" > right-click > File Operations > Rename to > select '...' and enter -

Code: [Select]
$insert(%filename%,19,$sub($len(%filename%),3))

^ This inserts 19 at 3 characters from the right.

Edit: Alternatively for either century...

Code: [Select]
$insert(%filename%,$ifgreater($num($right(%filename%,3),2),31,19,20),$sub($len(%filename%),3))

^ This tests "xx" and inserts 19 (if >31) or 20 (if <31) at 3 characters from the right. I think it should work for either century but always check the preview first.

The idea kode54 posted would work for tags except you needed more steps and having the steps in the correct order that was mentioned. Did you want to fix tags as well?

You can just copy filename to title if the above is sufficient - right-click tracks > Properties > Tools button > Automatically Fill Values > enter Pattern -

Code: [Select]
%%. %title%

^ If filename is "01. Get Back (01-12-2002)", title becomes "Get Back (01-12-2002)"

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #11
I had another idea. All the live performances file names end in "-xx]"
Is that something syntax could be used for to make it to "-19xx]"?
You only want to change the filenames?

Select the tracks that end in "-xx]" > right-click > File Operations > Rename to > select '...' and enter -

Code: [Select]
$insert(%filename%,19,$sub($len(%filename%),3))

^ This inserts 19 at 3 characters from the right.

Edit: Alternatively for either century...

Code: [Select]
$insert(%filename%,$ifgreater($num($right(%filename%,3),2),31,19,20),$sub($len(%filename%),3))

^ This tests "xx" and inserts 19 (if >31) or 20 (if <31) at 3 characters from the right. I think it should work for either century but always check the preview first.

The idea kode54 posted would work for tags except you needed more steps and having the steps in the correct order that was mentioned. Did you want to fix tags as well?

You can just copy filename to title if the above is sufficient - right-click tracks > Properties > Tools button > Automatically Fill Values > enter Pattern -

Code: [Select]
%%. %title%

^ If filename is "01. Get Back (01-12-2002)", title becomes "Get Back (01-12-2002)"

Yeah I don't care about the title tag. My organization system is set up to not need tags properly. Unfortunately I can't merely select the tracks that are live. They are littered throughout. Some albums have bonus live tracks and some are entirely live. Isn't there a way to set up a condition 'if last three letters are (between 70-99)] add 19 before (between 70-99)'?

And yes the formatting is consistent in that aspect. It's always ends for live tracks with [20-1-97] or [17-4-86] in the file name.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #12
Title formatting does not have wildcards to make it easy. It is better to search / make a playlist to apply rename to the correct files only.

If the filenames / titles have other text in common you can search for that. Looking at your screenshot, are they like this? -

Every Night [live 12-31-79]

If so you can easily go Library > Search -

Code: [Select]
%title% HAS [live

Or in this case -

Every Night [live 12-31-79] [DVD mix]
Code: [Select]
%title% HAS [live AND NOT %title% HAS [DVD mix]

(You could do similar search using %filename% instead if they match?)

Even better - have a look at that Porcus reply above. You can search in Windows Explorer with wildcards. Go to your root music folder, and assuming above patterns, type in the search box -

Code: [Select]
*-??].mp3
Code: [Select]
*-??].flac

(The extension helps keep it specific. I do not have the same filename patterns to test, so you might have to experiment)

How do the results look? Unfortunately there is no way around having to manually scan results with your eyes. See this guide to Windows Search if you need to refine it.

Then just select and drag results to a new foobar playlist and apply the File Operations rename from my reply above.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #13
Isn't there a way to set up a condition 'if last three letters are (between 70-99)] add 19 before (between 70-99)'?

And yes the formatting is consistent in that aspect. It's always ends for live tracks with [20-1-97] or [17-4-86] in the file name.

It is possible, certainly. But first, are you distinguishing between ")" and "]" here?
Also again: is this something you want to do *once* or will you have to do it again later and in the latter case: will you have to distinguish between those that are already fixed and those that are not?

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #14
Before things get more confusing let me clarify that both title and file names are identitical in how they end, i.e. [dd-mm-yy]

Sometimes they might have live before them but not always. And yes they always end with square brackets and never curved brackets.

Lastly using *-??] on Everything seems to have worked in bringing up all live tracks but of course I can't use Bulk Rename Utility when there's more than one folder. I managed to add them to foobar and here's the fpl if people need it for reference: https://we.tl/t-naIz6I5VcS

The title tag does indeed have the dates. Is there no mass command to add '20' if the value range is between '-00' to '17'?
You got like fifty CDs? That isn't much. Problem is if you are constantly getting new bootlegs in that old format. Then you need to be able to search up those which fit that pattern and ...

But if you only need to do it once, you can search up tracks for *-0?) OR *-1?) OR *-2?) and that will return everything that ends in -00) through -29) to get the 20 in front. You need to escape the parenthesis though. And if you have a mix of round parentheses and brackets, consider *??-??-0?? OR *??-??-1?? OR *??-??-2?? and see if that returns any false positives.
And then do similar to get the 19.

But, it is possible to code the 19 vs 20 in fb2k without IFs by using the fact that fb2k division rounds down to integer. $div(x,$max(x,22)) will return 0 if x is 0 through 21, and 1 if x is 22 or more. Subtract that from 20 to get 20 or 19 as appropriate.

What I would have done, is
* Split the track title between the first N-11 characters (to go into title) and the 8 running from N-9 to N-1 (to go into a new trackdateddmmyy tag).
* Fix the trackdateddmmyy tag into trackdate
* Apply a renaming that does not use "(" nor ")" for the dates, as parentheses are too commonly found in track titles. You can for example use a character like µ (the micron) or ¨; or if you insist on ASCII printable (non-"extended") I have no ` in metadata in my collection, and if you are equally lucky that character will uniquely be a separator. Say, 01. Get Back `01-12-2002.
... well of course you should use the useful date format for 01. Get Back `2002-12-01

I am sorry but I don't understand the steps you've written. Can you provide screenshots of what you mean?

Furthermore unless I had a live folder where yyyy-mm-dd would be beneficial by being chronoligcal using dd-mm-yyyy is vastly more preferable for searching because it's more intuitive for me.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #15
Lastly using *-??] on Everything seems to have worked in bringing up all live tracks ... I managed to add them to foobar and here's the fpl if people need it for reference:

Then you are good to go. Just switch to that playlist in foobar, select all tracks (CTRL-A), right-click > File Operations > Rename > '...' and enter -

Code: [Select]
$insert(%filename%,$ifgreater($num($right(%filename%,3),2),31,19,20),$sub($len(%filename%),3))

I checked the preview and both ranges of dates look fine, feel free to check it yourself before clicking Run.


Furthermore unless I had a live folder where yyyy-mm-dd would be beneficial by being chronoligcal using dd-mm-yyyy is vastly more preferable for searching because it's more intuitive for me.

For mind that suggestion was only for copying tags to the DATE field, where it should indeed be year first (the standard foobar recognizes for using $date functions)

For filenames / titles, either way is fine, whatever one prefers.

I did notice though your filename dates are actually month first (American standard) ... did you mean to change that? (That would be quite tricky because they also have no leading zeros, i.e. M-D-YY)

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #16
Before things get more confusing let me clarify that both title and file names are identitical in how they end, i.e. [dd-mm-yy]
... and always square brackets. That helps for identifying it.

If I were you I would still have considered to replace the "[" and "]" by something less likely to be found in actual titles though. If you have no "{" or "}" anywhere else, then a simple search for { would give you all those live dates and nothing else.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #17
Before things get more confusing let me clarify that both title and file names are identitical in how they end, i.e. [dd-mm-yy]
... and always square brackets. That helps for identifying it.

If I were you I would still have considered to replace the "[" and "]" by something less likely to be found in actual titles though. If you have no "{" or "}" anywhere else, then a simple search for { would give you all those live dates and nothing else.

Why do you want me to replace it with a different type of parenthesis? Square brackets are unique to this archive AFAIK. Everywhere I use circle brackets which are almost universal. Regardless what use would [ being replaced with { have? Square brackets are used for remixes, extended cuts, too so it's not limited to just live performances.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #18
Lastly using *-??] on Everything seems to have worked in bringing up all live tracks ... I managed to add them to foobar and here's the fpl if people need it for reference:

Then you are good to go. Just switch to that playlist in foobar, select all tracks (CTRL-A), right-click > File Operations > Rename > '...' and enter -

Code: [Select]
$insert(%filename%,$ifgreater($num($right(%filename%,3),2),31,19,20),$sub($len(%filename%),3))

I checked the preview and both ranges of dates look fine, feel free to check it yourself before clicking Run.


Furthermore unless I had a live folder where yyyy-mm-dd would be beneficial by being chronoligcal using dd-mm-yyyy is vastly more preferable for searching because it's more intuitive for me.

For mind that suggestion was only for copying tags to the DATE field, where it should indeed be year first (the standard foobar recognizes for using $date functions)

For filenames / titles, either way is fine, whatever one prefers.

I did notice though your filename dates are actually month first (American standard) ... did you mean to change that? (That would be quite tricky because they also have no leading zeros, i.e. M-D-YY)


It worked. Thanks for the help everyone. You've been very patient with me.

I also realized retaining the original title is going to be helpful in case there ever is a mix up.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #19
Why do you want me to replace it with a different type of parenthesis? Square brackets are unique to this archive AFAIK.
Then, no problem. In my collection, I have had external tag sources use square brackets in titles for
* different versions (that may or may not be live and would lead to like 04. Good Song [new rem19ix])
* bilingual track titles in the tag sources
* [untitled], [inverview part], or [stage banter while roadies fix guitar] in a bootleg
* catalog numbers like BWV's in Bach's works* track subtitles like https://www.discogs.com/The-Ocean-Precambrian/release/1524440 or different stanzas in classical works
* titles that do contain square brackets without any other reason than the artist choosing so, https://www.discogs.com/White-Darkness-Nothing/release/1056045 or https://www.discogs.com/Sundown-Halo/release/1219215

And also in album titles,  (or this) and even band name.


Re: foobar2000 mass rename xx year in file name to xxxx

Reply #20
I did notice though your filename dates are actually month first (American standard) ... did you mean to change that? (That would be quite tricky because they also have no leading zeros, i.e. M-D-YY)


Actually can't we just use if [x-] (1-9) then add 0 before 'x'? I am thinking of adding 0 before and then perhaps doing a dd mm swap

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #21
But my thought was it would take 4 searches (in Explorer), and 4-5 foobar rename operations, to account for each variation... i.e. insert 0 for [m-d-yyyy], [mm-d-yyyy], [m-dd-yyyy], and swap mm-dd.

(Again, foobar title formatting likes precision, there are no wildcards to help)

I actually had another look at Bulk Rename Utility, and inserting 0 can be done easily in that, but it looks like (unless I missed something) you'd need foobar to handle swapping characters. (Theoretically, I've not written any code)

So what do you want to do?

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #22
But my thought was it would take 4 searches (in Explorer), and 4-5 foobar rename operations, to account for each variation... i.e. insert 0 for [m-d-yyyy], [mm-d-yyyy], [m-dd-yyyy], and swap mm-dd.

(Again, foobar title formatting likes precision, there are no wildcards to help)

I actually had another look at Bulk Rename Utility, and inserting 0 can be done easily in that, but it looks like (unless I missed something) you'd need foobar to handle swapping characters. (Theoretically, I've not written any code)

So what do you want to do?

I can't use BRU. It doesn't have a directory rename feature AFAIK so I am stuck with foobar file name renaming.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #23
BRU can rename directories - but IIRC you need to do quite a bit of regexp manipulation to insert "20" at N places from the end.

Also foobar2000 search queries can use wildcards, although it is undocumented in the help. I suppose %filename% IS *-0?] OR %filename% IS *-1?] OR %filename% IS *-2?] should return returns those which need the "20" inserted (am I right? Not on my home computer at the moment.)

BTW, if you have an issue with single-digit and double-digit months and days, you can use custom tags (that can be removed afterwards). Because it is so that your title then has the form ACTUAL TITLE [date-month-year] where date or month are single or double figures?
(0) query up everything that has a date at the end.
(1) Properties -> right click, Automatically fill values. Choose Other and %title%.
(2) Pattern, assuming those tags are un-used and free to abuse: %actualtracktitle% [%livedate%-%livemonth%-%liveyear%]
(3) Another Automatically fill, populate %recordeddate% by $num(%livedate%,2)-$num(%livedate%,2)-[and here you apply the year fix]

I would have used actual title for title (so that all versions of Enter Sandman have "Enter Sandman" as title) and then renamed using %title% and %recordeddate% ... but up to you.

Re: foobar2000 mass rename xx year in file name to xxxx

Reply #24
Also foobar2000 search queries can use wildcards, although it is undocumented in the help. I suppose %filename% IS *-0?] OR %filename% IS *-1?] OR %filename% IS *-2?] should return returns those which need the "20" inserted (am I right? Not on my home computer at the moment.)

(You are right)
Wow, that is news to me (or maybe I forgot) - that would be handy.

I can't use BRU. It doesn't have a directory rename feature AFAIK so I am stuck with foobar file name renaming.
Do you mean search? (It can rename folders)

You can use BRU to insert numbers - select root folder, use wildcard Filter to search "subfolders" (select it), and Add 0 at a negative position -

X

^ Screenshot. You would just have to use a few wildcards to fix every date variation individually, because the insert positions are different. For example -

Code: [Select]
*[?-?-????]*
*?-??-????]*
*??-?-????]*

(Files with "[live " (etc) might show up, so select the correct files carefully, or try with an "[" in there)

Same reason I said you'd need 4 rename operations if using foobar. Then finally you could just use foobar to swap mm-dd around. (BRU seems to only let you move first/last text, not text in the middle, and unfortunately I do not know regex or whether that would help)