Renaming Music Videos

Talk about the Ultimate Question of Life, The Universe, and Everything
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Renaming Music Videos

Post by barndotcom »

Hello,

Here’s my situation. I have a very large library of music videos, roughly 30,000-35,000 of them. In the earlier days of collecting, I adopted a naming convention that emphasized short filenames and a limited character set so that my videos would work with a serial-controlled computerized playback system that would choke on funky characters and long strings.

Almost 15 years later, my Windows NT-based Video Jukebox is long gone, replaced by the more modern media centre software Plex, and I want to likewise upgrade my filenames so they are more intelligible, searchable, and matchable to metadata providers. (I actually run a site that provides music video metadata - http://www.rockpeaks.com/web-services - via an API, and plan on building an agent for Plex, but that’s another story).

Here’s how my folder system is structured and files currently named:

/Music Video
------> /A
------> /B
------> /C
------> /Cabaret Voltaire
------> /Cage the Elephant
------> /Cake
------> /Cale, John
------>1975 06-07 - Crystal Palace Park
------>Cale_John_01_Fear_is_a_Man's_Best_Friend_Crystal_Palace_Park_75.mpeg
------>Cale_John_02_Buffalo_Ballet_Crystal_Palace_Park_75.mpeg
------>1985 - Old Grey Whistle Test
------>Cale_John_Dying_On_The_Vine_OGWT_85.mpeg

So you can see that while my folder names have spaces in them, my filenames do not, using underscores instead. And while the folder name has the full show name and full date, I very often abbreviated both in the filename itself to shorten its length. And where there is a sequence number to preserve the sort or playback order, those double-digit numbers come after the artist name.

The convention I’d ideally like to adopt for filenames going forward is this:

01 - John Cale - Fear Is A Man’s Best Friend - Crystal Palace Park - 1975.mpg

What I’d like to do is automate the following as much as possible (realizing that a certain amount of manual intervention is inevitable, and not all of this may be possible).

It seems to make sense to me to work from back to front on the filenames, given how they are structured. So:

(1) Convert to four digit years. The logic, as best as I can express it, would be something like this. Look for two digit numerals towards the end of a filename string and where the first of the digits is 2 or greater, prepend “ - 19”. If the the leading digit is less than 2, prepend “ - 20”.

This would result in the first of the files above having the new name:

Cale_John_01_Fear_is_a_Man’s_Best_Friend_Crystal_Palace_Park - 1975.mpeg

A couple of caveats. In some cases, the filename may already have a four digit year, in which case just the replacing of the underscore with a “ - “ would be required.

In some other cases, the year numerals are not the last characters before the file extension. Example:

ACDC_It’s_A_Long_Way_To_The_Top_Bandstand_76_(digital_rebroadcast).mpeg

(2) Very often the show name is abbreviated, as mentioned. Ideally, we would be able to grab the full show name from the containing folder, look for a full or partial partial match in the filename, and replace that match with the full name and a leading “ - “ , giving us:

Cale_John_01_Fear_is_a_Man’s_Best_Friend - Crystal Palace Park - 1975.mpeg

A potential issue with this one: Sometimes matching based on similar sequences of characters will be difficult or perhaps impossible, since an abbreviation has been used (Like the example above of “OGWT” for “Old Grey Whistle Test”). However, a limited number of abbreviations tend to occur frequently, I.e. TOTP for Top Of The Pops, SNL for Saturday Night Live etc.. so perhaps there is a way to draw on a reference table of common abbreviations?

(3) The third step would be to determine the division point between the song name and the artist name and place a “ - “ there. I could see how In cases where the two digit sequence numbers are present this would be easier, but there are lots of circumstances where there is just a single clip. In those cases, might it be possible to rely on a third-party matching service for artist names perhaps? Or maybe we go two levels up the folder tree and grab the name from there?

Or maybe this is a case where I would simple have to manually identify the division point once for an artist, and then for the remaining clips in that folder, Filebot would follow the same pattern? While I use the format "Last Name, First Name" for proper artist names in the folders, I would like to swap the order for the filenames themselves, and have a consistent and universally recognized exact spelling and formatting for artist names.

(4) The last step would be to swap the remaining underscores for spaces, and move the sequence numbers (if present) before the artist name instead of after it.

Thanks in advance for your help!

Barn
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

1.
So the new filename is entirely based on known information (folder name, file name, custom text mappings) right? No music identification necessary at all?

The FileBot Format for that might be quite long, but I'm pretty sure it's doable even within the UI:
viewtopic.php?f=3&t=2072


2.
Let's just take one file as an example, and get started with that:

Code: Select all

Music Video/C/Cale, John/1975 06-07 - Crystal Palace Park/Cale_John_01_Fear_is_a_Man's_Best_Friend_Crystal_Palace_Park_75.mpeg
So this is the folder structure right? Is this correct? Is it always the same for all files?

Code: Select all

Letter/Artist/Year-Album/Artist_Number_Title_Album_Year

3.
Paste this Generic File Format and see what happens:

Code: Select all

{
	def artist = file.dir.dir.name.tokenize(',')*.trim().join(' ');
	def year = fn.matchAll(/\d{2,4}/).last();
	def number = fn.before(year).match(/\d{2}/);
	def album = file.dir.name.after(' - ');
	def title = fn.before(year).after(number).space(' ').before("${album}|${album.acronym()}");

	[artist, number, album, title, year.pad(4, '19')].join(' -- ')
}
Please try this with some of your files. This should work for the first few files now. Please try it with a few more files, find the ones that don't work correctly yet, and send me the file paths so I can improve things step by step.

Right now we're just testing if can extract all the information for each file correctly. Once we have confirmed that we can get all the variables correctly, we can get started on building the exact output path pattern you want.
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Fantastic rednoah, thanks for responding so promptly!

To answer your questions:
rednoah wrote:1.
So the new filename is entirely based on known information (folder name, file name, custom text mappings) right? No music identification necessary at all?
Yes, that is correct, no music identification necessary.
rednoah wrote:So this is the folder structure right? Is this correct? Is it always the same for all files?
Code: Select all
Letter/Artist/Year-Album/Artist_Number_Title_Album_Year
Pretty close. Where you have the word "Album" I would substitute the word "Show". Also, not every video has a sequence number. And the date in the containing folder can vary depending on how much info there is about a clip. Sometimes it is just the four-digit year, sometimes it also includes the month and day as well.

But otherwise, this is pretty much correct:

Letter/Artist/Year Month-Day - Show/Artist_Number_Title_Show_Year
rednoah wrote:3.
Paste this Generic File Format and see what happens:
Here is what I got as a result with the first example using the code snippet you provided:

Cale John -- 01 -- Crystal Palace Park -- Fear is a Man's Best Friend -- 1975

Pretty good! We have definitely succeeded in extracting all the information correctly.

Ways I could see to improve things would include:

• Switching the order of the Show and the Title
• Moving the sequence number to the first position
• Switching the order to First Name Last Name

For this last request, the code would first need to make sure the artist was a person and not a band name, I suppose the method would be to check if the name had two words and that there was a comma immediately after the first word.

I tried a second time on this file:

C/Cale, John/1985 - Old Grey Whistle Test/Cale_John_Dying_On_The_Vine_OGWT_85

And got the message "ScriptException: java.lang.Exception: Pattern not found"

This could be due to the lack of a sequence number. Other differences are that the containing folder only has the year (no month or day) and that the show name is abbreviated in the filename.

Very encouraged by the progress so far!
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

1.
Alright, I've added this to my test data:

Code: Select all

Music Video/C/Cale, John/1985 - Old Grey Whistle Test/Cale_John_Dying_On_The_Vine_OGWT_85.mpeg

Please try this with another set of files:

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',').reverse()*.trim().join(' ');
	def year = fn.matchAll(/\d{2,4}/).last();
	def number = any{fn.before(year).match(/\d{2}/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def title = fn.before(year).after(number).space(' ').before("${show}|${show.acronym()}");

	[number, artist, title, show, year.pad(4, '19')].findAll{ it.length() > 0 }.join(' -- ')
}
2.
What folder structure do you want?
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

The new code snippet worked well on the Old Grey Whistle test file, with one exception: the name of the artist was repeated:

Code: Select all

John Cale -- Cale John Dying On The Vine -- Old Grey Whistle Test -- 1985
If we could get rid of the second instance of the artist name that would be fantastic.

I tested the new snippet with the earlier file and it worked perfectly:

Code: Select all

01 -- John Cale -- Fear Is A Man's Best Friend -- Crystal Palace Park -- 1975
I tried some other files in my John Cale folder, like this one

Code: Select all

Music Video/C/Cale, John/2003 - BBC Sessions St. Lukes
Cale_John_02_Ship_Of_Fools_BBC_St_Lukes_2003


The output I got was:

Code: Select all

02 -- John Cale -- Ship of Fools BBC St Lukes -- BBC Sessions St Lukes -- 2003
This was likely due to the mismatch between the show name in the containing folder and the show name in the filename itself. There are going to be a bunch of these cases where I have shortened the show name in some fashion in the file name. Is there a way you can think of to do partial or fuzzy matching?

Here's another fairly common example:

Code: Select all

Music Video/C/Cale, John/2003 10-03 - Later with Jools Holland
Cale_John_Venus_in_Furs_Later_03
The output I got was:

Code: Select all

John Cale -- Cale John Venus in Furs Later -- Later with Jools Holland -- 1903
Interestingly, the artist name repeated here, as in the first example in this post, but not the second or third.

The short show name "Later" gets included with the title again.

And the year is off by 100 years :-) My original thinking to get around this problem was:
Look for two digit numerals towards the end of a filename string and where the first of the digits is 2 or greater, prepend “ - 19”. If the the leading digit is less than 2, prepend “ - 20”.
Regarding folder structure, there don't need to be any changes there. I just need to make sure my artist names and my show names are exactly as I want them, which I'll have to double-check manually.
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

1. Year is now based on the folder name which seems to be more reliable.
2. Artist/Reverse issue has been fixed.

Try this:

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
	def year = file.dir.name.match(/\d{4}/);
	def trail = "${year}|${year[2..3]}";
	def number = any{fn.before(trail).match(/\d{2}/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def title = fn.space(' ').before(trail).after(artist.join(' ')).after(number).before("${show}|${show.acronym()}");

	[number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}

3. The "BBC St Lukes" VS "BBC Sessions St Lukes" issue is tricky. I could try to cut off at "BBC", meaning we assume the the title won't contain the first word of the show, which seems questionable.

Try this:

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
	def year = file.dir.name.match(/\d{4}/);
	def yearTrail = "${year}|${year[2..3]}";
	def number = any{fn.before(yearTrail).match(/\d{2}/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def showTrail = "${show}|${show.acronym()}|${show.tokenize().first()}";
	def title = fn.space(' ').before(yearTrail).after(artist.join(' ')).after(number).before("($showTrail)(?!.*($showTrail))");

	[number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Excellent!

Your second code snippet does indeed render the BBC St Luke's filename correctly. And the other issues are fixed as you say.

I have tried the final snippet on a bunch of files at random and had very good results. There are a few exception conditions here and there, but these are unique naming cases and it does not make sense to try and code around them.

However, I did want to ask you about one thing, which is where there are numerals in the band name or the clip's title: that seems to break things. Again, I can live with it if it is too tricky to code around, but I thought I would just ask. Here are some examples:

Code: Select all

Babes in Toyland
1995 07-09 - 120 Minutes
Babes_in_Toyland_Sweet_69_120_Minutes_95
Gives Me:

Code: Select all

69 -- Babes in Toyland -- 120 Minutes -- 1995
(The numerals in the show name seem to be fine, but it is the 69 in the title that breaks the code)

And this one:

Code: Select all

B-52s
1998 08 - VH1 Big Backyard BBQ
B52s_01_Introduction_VH1_Big_Backyard_BBQ_1998
Gives me:

Code: Select all

52 -- B-52s -- s 01 Introduction -- VH1 Big Backyard BBQ -- 1998
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

1.
Making a few more assumptions based on the examples I've got so far:

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
	def artistHead = artist.join(' ').replaceAll(/\W|_/, '.?');
	def year = file.dir.name.match(/\d{4}/);
	def yearTrail = "${year}|${year[2..3]}";
	def number = any{fn.space(' ').before(yearTrail).after(artistHead).match(/^\d{2}/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def showTrail = "${show}|${show.acronym()}|${show.tokenize().first()}";
	def title = fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))");

	[number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}
2.
If you want to "edit" the target name in FileBot before renaming you can do that as well by hitting F2 on selected items.
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Looking good! A few anomalies still though, but I don't want to try your patience. If these are too persnickety, I can definitely live with things as the way they are.

If you're feeling up to some further tweaks however....

For some reason:

Code: Select all

B52s_03_Private_Idaho_Big_Backyard_BBQ_1998
B52s_04_Channel_Z_Big_Backyard_BBQ_1998
B52s_05_Good_Stuff_Big_Backyard_BBQ_1998
Renames as

Code: Select all

03 -- B-52s -- Private Idaho Big Backyard BBQ -- VH1 Big Backyard BBQ -- 1998
04 -- B-52s -- Channel Z Big Backyard BBQ -- VH1 Big Backyard BBQ -- 1998
05 -- B-52s -- Good Stuff Big Backyard BBQ -- VH1 Big Backyard BBQ -- 1998
Part of the show name is repeating at the end of the title. I presume the numeral "1" that is part of VH1 is what is tripping up the code, but curious why it does on only some of the titles. This one is fine:

Code: Select all

B52s_02_Party_Out_Of_Bounds_VH1_Big_Backyard_BBQ_1998
As is the Babes in Toyland clip.

I have spent a bunch more time testing. One other thing I have noticed is that when there is a comma in a show name, the part after the comma gets appended to the title.

Example:

Code: Select all

1985 07-13 - Live Aid, JFK Stadium
Beach_Boys_01_Wouldn't_It_Be_Nice_JFK_Stadium_85.mpeg
Renames as:

Code: Select all

01 -- Beach Boys -- Wouldn't It Be Nice JFK Stadium -- Live Aid, JFK Stadium -- 1985

And finally, I have experimented with dropping entire Artist folders on Filebot, to gauge the speed with which I'll be able to work through my collection. I also keep non-video files in folders (DVD art, text info files) and I was pleased to see that I could easily just exclude them by clicking the red 'X" at the bottom of the program window.

Here's a sample of a whole artist drop:

Code: Select all

Barenaked Ladies
	2001 - Intimate and Interactive
		Barenaked_Ladies_01_Intro_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_02_The_Old_Apartment_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_03_Pinch_Me_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_04_Jane_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_05_Interview_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_06_One_Week_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_07_Ad_Lib_Gluehead_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_08_What_a_Good_Boy_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_09_Discussion_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_10_Its_All_Been_Done_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_11_Brian_Wilson_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_12_Interview_2_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_13_Falling_for_the_First_Time_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_14_If_I_Had_a_Million_Dollars_Intimate_and_Interactive_01.mpeg
		Barenaked_Ladies_15_Call_and_Answer_Intimate_and_Interactive_01.mpeg
		BNL I&I 2001.txt
		IntimateandInteractive.jpg
	2001 02 - VH1 Grammys Preview
		Barenaked_Ladies_Grammys_Nominees_VH1_Grammys_Preview_01.mpg
		BNL I&I 2001.txt
	2001 02-15 - Live with Regis and Kelly
		Barenaked_Ladies_01_Intro_Live_with_Regis_and_Kelly_01.mpg
		Barenaked_Ladies_02_Too_Little_Too_Late_Live_with_Regis_and_Kelly_01.mpg
		Barenaked_Ladies_03_Outro_Live_with_Regis_and_Kelly_01.mpg
		Barenaked_Ladies_04_Interview_Live_with_Regis_and_Kelly_01.mpg
		Barenaked_Ladies_05_The_Old_Apartment_Live_with_Regis_and_Kelly_01.mpg
		Barenaked_Ladies_06_Its_All_Been_Done_Live_with_Regis_and_Kelly_01.mpg
		Barenaked_Ladies_07_One_Week_Live_with_Regis_and_Kelly_01.mpg
		BNL I&I 2001.txt
	2001 12-06 - AV Squad
		AVSquad.jpg
		Barenaked_Ladies_01_Interview_AV_Squad_01.mpeg
		Barenaked_Ladies_02_Ad_Lib_AV_Squad_01.mpeg
		Barenaked_Ladies_03_Interview_2_AV_Squad_01.mpeg
		Barenaked_Ladies_04_One_Week_AV_Squad_01.mpeg
		BNL I&I 2001.txt
	2006 - Tonight Show With Jay Leno
		Barenaked_Ladies_Wind_It_Up_Leno_06.mpg
However, I did notice that for some reason, the first file in a subfolder tended to not get renamed correctly:

Code: Select all

Barenaked Ladies -- Intimate and Interactive -- 2001
02 -- Barenaked Ladies -- The Old Apartment -- Intimate and Interactive -- 2001
03 -- Barenaked Ladies -- Pinch Me -- Intimate and Interactive -- 2001
...

Barenaked Ladies -- Live with Regis and Kelly -- 2001
02 -- Barenaked Ladies -- Too Little Too Late -- Live with Regis and Kelly -- 2001
03 -- Barenaked Ladies -- Outro -- Live with Regis and Kelly -- 2001
...
If this is an easy tweak, it would be great to see it happen, but honestly, I can live with it.

Thanks for the tip on hitting F2 to rename a file - very useful! (One observation: the dialog box that pops up is very narrow and one has to scroll a lot within it. Ideally it would show as much of the filename as possible)

Thank you so much for your help on this rednoah, I was dreading this job, and thanks to your excellent program and generous help it is going to be much easier. A donation is coming your way right now.
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

* Fix issue when number equals year
* Match title before any show sub pattern

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
	def artistHead = artist.join(' ').replaceAll(/\W|_/, '.?');
	def year = file.dir.name.match(/\d{4}/);
	def yearTrail = "(${year}|${year[2..3]})(?!.*(${year}|${year[2..3]}))";
	def number = any{fn.space(' ').before(yearTrail).after(artistHead).match(/^\d{2}/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def showTrail = [show.tokenize().reverse().inject{t, h -> "(($h ($t)?)|$t)" }, show.acronym()].join('|');
	def title = fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))");

	[number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Great stuff, everything working beautifully so far, thanks so much again for your kind assistance. I'll be hanging out with Filebot and my music video collection for the next little while :-)

Barndotcom
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

Alrighty, glad it's working well!

Here's my test data in case anybody wants to play with this, and see how we got to a good-enough solution step by step:

Code: Select all

Music Video/C/B-52s/1998 08 - VH1 Big Backyard BBQ/B52s_01_Introduction_VH1_Big_Backyard_BBQ_1998.ts
Music Video/C/B-52s/1998 08 - VH1 Big Backyard BBQ/B52s_03_Private_Idaho_Big_Backyard_BBQ_1998.ts
Music Video/C/Babes in Toyland/1995 07-09 - 120 Minutes/Babes_in_Toyland_Sweet_69_120_Minutes_95.ts
Music Video/C/Barenaked Ladies/2001 - Intimate and Interactive/Barenaked_Ladies_01_Intro_Intimate_and_Interactive_01.mpeg
Music Video/C/Beach Boys/1985 07-13 - Live Aid, JFK Stadium/Beach_Boys_01_Wouldn't_It_Be_Nice_JFK_Stadium_85.mpeg
Music Video/C/Cale, John/1975 06-07 - Crystal Palace Park/Cale_John_01_Fear_is_a_Man's_Best_Friend_Crystal_Palace_Park_75.mpeg
Music Video/C/Cale, John/1985 - Old Grey Whistle Test/Cale_John_Dying_On_The_Vine_OGWT_85.mpeg
Music Video/C/Cale, John/2003 - BBC Sessions St. Lukes/Cale_John_02_Ship_Of_Fools_BBC_St_Lukes_2003.mpeg
Music Video/C/Cale, John/2003 10-03 - Later with Jools Holland/Cale_John_Venus_in_Furs_Later_03.mpeg
PS: Barnie has donated 100 € for my work on this, which is reasonable and fair considering the amount of time and effort involved. Just in case anyone is wondering how much a few "simple" lines of custom code are worth. ;)
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Indeed, the time and effort you put in was well worth the donation and is much appreciated.


I do notice after some time using the latest code that the comma issue still persists in some cases, placing what preceded the comma into the clip title.

This renames fine:

Code: Select all

1991 9-28 - Tushino Airfield, Moscow
01 -- ACDC -- Back In Black -- Tushino Airfield, Moscow -- 1991
But this renames as follows:

Code: Select all

1983 12-12 - Landover, MD
01 -- ACDC -- Flick Of The Switch Landover -- Landover, MD -- 1983
A small thing, but if it is an easy fix it would be appreciated!
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

I can't test this without the original filename that doesn't work, but this might fix the problem:

Code: Select all

{
   def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
   def artistHead = artist.join(' ').replaceAll(/\W|_/, '.?');
   def year = file.dir.name.match(/\d{4}/);
   def yearTrail = "(${year}|${year[2..3]})(?!.*(${year}|${year[2..3]}))";
   def number = any{fn.space(' ').before(yearTrail).after(artistHead).match(/^\d{2}/)}{''};
   def show = file.dir.name.after(' - ').space(' ');
   def showTrail = [show.replaceAll(/\p{Punct}/, '.?').tokenize().reverse().inject{t, h -> "(($h ($t)?)|$t)" }, show.acronym()].join('|');
   def title = fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))");

   [number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

An improvement, but I am still finding problems with commas in show names, for instance:

Code: Select all

1983 10-30 - The Summit, Houston Texas
ACDC_Shoot_To_Thrill_Houston_83.mpeg
Will rename as follows:

Code: Select all

ACDC -- Shoot To Thrill Houston -- The Summit, Houston Texas -- 1983
And:

Code: Select all

1996 7-5 - VH1 Studio B, London, England
ACDC_Gone_Shootin_London_96.mpeg
Will rename as follows:

Code: Select all

ACDC -- Gone Shootin London -- VH1 Studio B, London, England -- 1996
Not a huge deal to manually delete the extra word, but it would be great if it didn't happen - every extra second saved helps cut down the time I'll be doing this job!
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

More rules:

Code: Select all

{
   def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
   def artistHead = artist.join(' ').replaceAll(/\W|_/, '.?');
   def year = file.dir.name.match(/\d{4}/);
   def yearTrail = "(${year}|${year[2..3]})(?!.*(${year}|${year[2..3]}))";
   def number = any{fn.space(' ').before(yearTrail).after(artistHead).match(/^\d{2}/)}{''};
   def show = file.dir.name.after(' - ').space(' ');
   def showTrail = [show.replaceAll(/\p{Punct}/, '.?').tokenize().reverse().inject{t, h -> "(($h ($t)?)|$t)" }, show.tokenize(',')*.trim()*.tokenize(' ')*.first().join('|'), show.acronym()].join('|');
   def title = fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))");

   [number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Fantastic, that worked like a charm.

I have just spent two hours happily renaming files, and have no other issues to report with regards to the renaming code.

I do have a couple of observations about the FileBot UI that you may want to consider the next time you make an update to the program.

One is my earlier observation about the width of the dialog box that comes up when you press F2 to manually rename a file - it would be great if it were wider.

It would also be nice if the up/down keyboard arrow keys functioned to move the highlight bar through the list of files in the active window pane. My workflow involves dropping a large number of folders + subfolders on FileBot and then removing the ones I don't want renamed. Currently this involves a lot of mouse movement to go between the file and the red X below, and it would be much faster if I could use both the keyboard and the mouse in tandem.

Normally I drop an entire Artist folder, with many sub-folders on FileBot without any problem. However, if I select two or more folders that are at the same level in my HD directory tree and drop them on FileBot, all the files appear twice for some odd reason.

All of these are very minor quibbles, and may be unique to the particular way I am using the program, but I just thought I would pass along the feedback.

Overall, you have written an amazingly useful application, and your support is outstanding. I thank you again for all your help red noah!

Barn
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

1.
The F2 "Edit Name" feature can't be made resizable (unless I change 1 line to many lines). Also, with a perfect format you should even need manually edit a name in the first place.

2.
UP/DOWN moves the selection up and down. DELETE removes the selected row. There is no need to use the mouse when checking through matches. Is that not working for you?

3.
I can't reproduce the drag-n-drop issues you describe. What operating system are you using? What application are you dragging files from?

You say dragging folders A and B into FileBot will result in 4 files being added into list?

Code: Select all

A/a.txt
B/b.txt
This is unlikely to be a general issue, because somebody would have noticed that already. :D
:idea: Please read the FAQ and How to Request Help.
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

I can definitely live with #1.

Regarding #2, I didn't think to try the delete key (duh) so I was toggling between the up down keys and the red x (with the mouse), and thus the window was losing focus, which is why I thought the up down keys were not working. All good now, just using the keyboard.

#3 is not something that I can reproduce consistently, and may have been a weird temporary anomaly. if I find I can reproduce, I'll let you know.

Thanks again! Back to renaming.....
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Howdy Red Noah,

I've just returned to FileBot after some months away from my renaming task, and started to pick up where I left off. Using the same syntax you developed above (07 Feb 2016 post has the latest code) I am now getting "[Expression yields empty value: null]" when trying to rename for some reason.

I have not changed anything in terms of my original file naming, folder structure convention etc.. I did update my Mac OS to 10.12.6, and possibly FileBot itself has been updated since I last tried (running 4.7.12 (5176)

I'm sure it is something simple that I'm missing, or have forgotten. Any ideas? Not sure exactly how to use the "Groovy Pad" you mention when trying to debug in the GUI...
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

I just tested in the GUI
Path/file demo
Cale, John\1975 06-07 - Crystal Palace Park\Cale_John_01_Fear_is_a_Man's_Best_Friend_Crystal_Palace_Park_75.mpeg
output
01 -- John Cale -- Fear is a Man's Best Friend -- Crystal Palace Park -- 1975
using this code = look fine to me ?

Code: Select all

{
   def artist = file.dir.dir.name.space(' ').tokenize(',')*.trim();
   def artistHead = artist.join(' ').replaceAll(/\W|_/, '.?');
   def year = file.dir.name.match(/\d{4}/);
   def yearTrail = "(${year}|${year[2..3]})(?!.*(${year}|${year[2..3]}))";
   def number = any{fn.space(' ').before(yearTrail).after(artistHead).match(/^\d{2}/)}{''};
   def show = file.dir.name.after(' - ').space(' ');
   def showTrail = [show.replaceAll(/\p{Punct}/, '.?').tokenize().reverse().inject{t, h -> "(($h ($t)?)|$t)" }, show.tokenize(',')*.trim()*.tokenize(' ')*.first().join('|'), show.acronym()].join('|');
   def title = fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))");

   [number, artist.reverse().join(' '), title, show, year].findAll{ it.length() > 0 }.join(' -- ')
}
when you open the GUI drag/drop files on org. files then press "F2" key copy/paste the code, done
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Hi Kim,

Thanks for taking the time to check this. Things are working for me now, I wasn't following the procedure correctly before.

Barnaby
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Hello, I had a small follow-up request regarding the rename code above, which has been working very well for me for years.

In some renaming contexts I'm now stripping away most of the old filename, leaving just a signal digit or double digit number and the file extension, i.e.

1.mp4
2.mp4
...
11.mp4 etc.

I would love it if the code above could be tweaked to allow for files with this simple naming to be renamed as well, currently I get the 'Expression yields empty value' message when I try.

Thank you,

Barnaby
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

"renamed as well"
to what ?

Code: Select all

{
   any{def artist
...
.join(' -- ')}{fn}
}
@rednoah
you really need to do something... cant even post SAME CODE AS ABOVE
BAD REQUEST
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Renaming Music Videos

Post by rednoah »

kim wrote: 22 Jan 2021, 02:37 you really need to do something... cant even post SAME CODE AS ABOVE
BAD REQUEST
Unfortunately, since this is running on a shared host, I don't control the WAF configuration files...


EDIT:

Maybe we can maintain example format snippets at a centralized location in GitHub?
https://github.com/filebot/docs


EDIT 2:

I've started something here. I'll add you as contributor if you PM me your GitHub ID:
https://github.com/filebot/docs/blob/ma ... /format.md

Editing via GitHub should be easy, but organizing things might be tricky after a while, though we've given up on that here on the forums as well, can't be helped.
:idea: Please read the FAQ and How to Request Help.
Post Reply