Renaming Music Videos

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

Re: Renaming Music Videos

Post by barndotcom »

Hi Kim,

Sorry for not including more info. This graphic should help explain things a bit further:

Image

You can see how the files in the "House of Blues" folder renamed successfully, based on (1) the top level Artist folder name, and (2) the containing Show folders, that include the date.

However, the script does not work for files that don't have the sequence number and the double hyphen.

Hmm, the link to the image does not seem to work - here is the URL: https://www.dropbox.com/s/po8xsqsotqxlq ... e.png?dl=0
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

I'm not sure what the pre-renamed filename/path is and the wanted filename/path ?
... but try this:

Code: Select all

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

	[number, artist, title, show, year.pad(4, '19')].findAll{ it?.length() > 0 }.join(' -- ')
}
If not ok you need to post in text the:
pre-renamed filename/path AND the wanted filename/path
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Thank you Kim, unfortunately using that code on a file called "13.mp4" gave me this:

13 -- Joe Jackson -- Late Night with Conan O'Brien -- 1913.mp4

What I would ideally like is for the "13" to be placed after the artist name, as the temporary song title placeholder, like this:

Joe Jackson -- 13 -- Late Night with Conan O'Brien -- 2003.mp4

And for the correct year - 2003 - to be used at the end, instead of 1913.

Then all I have to do is manually paste in the song title over the "13" and I'm done.

The previous code is almost working, it gives me this when the filename has two characters, i.e.:

13 -- Joe Jackson -- Late Night with Conan O'Brien -- 2003.mp4

but if the filename has only one character, like 7.mp4, I get

[Expression yields empty value: null] 7
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

because wanted filename NEED info from path you NEED to write the path (ALL needed info or bad code)
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Sorry Kim, the path structure is as follows:

Joe Jackson > 1989 06-08 - Late Night with David Letterman > 0.mp4

or

Joe Jackson > 1989 07-12 - The Arsenio Hall Show > 1.mp4
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

so the "number" was never in the right place?

try:

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',').reverse()*.trim().join(' ');
	def year = any{file.name.match(/((?:19|20)\d{2})/)}{file.dir.name.match(/((?:19|20)\d{2})/)};
	def number = any{fn.before(year).match(/\d{2}/)}{fn.match(/^\d+/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def title = any{fn.before(year).after(number).space(' ').before("${show}|${show.acronym()}")}{''};
	[artist, title, number, show, year].findAll{ it?.length() > 0 }.join(' -- ')
}
add .pad(4, '19') to year

maybe replace

Code: Select all

{fn.before(year).match(/\d{2}/)}
with

Code: Select all

{fn.match(*/*[_ ]*(\d{2})*[_ ]*/*)}
remove the *'s
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

That works for a single file now Kim, which is great, but unfortunately for multiple files that have correct new double digit sequence numbers, things don't work as expected. Hopefully this explains the problem: https://www.dropbox.com/s/mdize54komleg ... b.png?dl=0
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

so always the same number ?

try add:

Code: Select all

[number?.pad(2), artist
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

After spending some time on format and research I believe this is what you want ?
e.g. looking at https://rockpeaks.com

Code: Select all

{
	def artist = file.dir.dir.name.space(' ').tokenize(',').reverse()*.trim().join(' ');
	def year = any{file.name.match(/((?:19|20)\d{2})/)}{file.dir.name.match(/((?:19|20)\d{2})/)};
	def number = any{fn.match(/[_ ](\d{2})[_ ]/)}{fn.match(/^\d+/)}{''};
	def show = file.dir.name.after(' - ').space(' ');
	def title = any{fn.space(' ').replaceAll(/\s--\s|((?:19|20)?\d{2}\s\(.+\)$)|\s?${year}$|\s?\d{2}$|${artist}|${show}|${show.acronym()}|${show.removeAll(/(.+),./)}|${artist.tokenize(' ').reverse().join(' ')}|${number}|${artist.removeAll(/-/)}/,'')}{number};

	[artist, title, show, year].findAll{ it?.length() > 0 }.join(' -- ')
}
As this looks to be for a business, you can pay me/us back by giving access to your site's API so rednoad can add support for music video in Filebot ;)
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Hi Kim,

I really appreciate all your work and help on this issue. Glad you checked out RockPeaks! I would be happy to explore an API integration between the site and Filebot, let's definitely start that conversation. Our public API is underdeveloped at this point, but maybe now is the time to start building it out.

Not sure if you looked at the Forum section, but I link to and recommend Filebot in this post: https://forum.rockpeaks.com/t/using-fil ... e-files/89

Thank you for the updated script, I've tested it out. There are still a few issues unfortunately.

Part of what makes my use case complex is that there are two broad types of files I'm dealing with those that have sequence numbers and those that don't. In the music video world, song clips from concerts should have sequence numbers, but collections of MTV-style promo videos don't need them.

Here is a grab of a folder - for the artist Squeeze - that has two show subfolders, one a concert, the other a collection of promos:

https://www.dropbox.com/s/c683xx7qi4zmo ... s.png?dl=0

Here is what happens with the new script when I try and process the concert with sequence numbers:

https://www.dropbox.com/s/djibuhi3c9kmg ... s.png?dl=0

Here is what happens when I try and process the folder of promo videos with no sequence numbers:

https://www.dropbox.com/s/5v7asx7g8s4hr ... s.png?dl=0

For comparison's sake, here is what happens with the original script that Rednoah wrote a few years back:

With sequence numbers:

https://www.dropbox.com/s/k0oywogbpd9ab ... s.png?dl=0

Without sequence numbers:

https://www.dropbox.com/s/t73g73olwzypc ... s.png?dl=0

Maybe what I'm after is too complex for one script?
kim
Power User
Posts: 1097
Joined: 15 May 2014, 16:17

Re: Renaming Music Videos

Post by kim »

I went back to rednoah's LAST format and modified it (bad move using early format as base):

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{1,2}/)?.pad(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 = any{fn.space(' ').before(yearTrail).after(artistHead).after(number).before("($showTrail)(?!.*($showTrail))").replaceAll(/--\s/)}{fn.space(' ').before(yearTrail).after(artistHead).before("($showTrail)(?!.*($showTrail))")};

   [number, artist.reverse().join(' '), title?.pad(2), show, year].findAll{ it?.length() > 0 }.join(' -- ')
}
barndotcom
Donor
Posts: 19
Joined: 27 Jan 2016, 23:43

Re: Renaming Music Videos

Post by barndotcom »

Fantastic Kim, that worked like a charm! Perfect!

Really appreciate all your help, let's schedule a time to chat about API integration when it suits,

Best,

Barnaby
Post Reply