Music Video Renaming Based On File Name, please help - new user

Any questions? Need some help?
Post Reply
RandomNinjaAtk
Posts: 2
Joined: 29 Jun 2017, 21:38

Music Video Renaming Based On File Name, please help - new user

Post by RandomNinjaAtk »

I tried searching and have found some good information but not enough for me to figure this out on my own. Anyways, I want to rename Music Videos based on file name below, most of my videos typically have a name structure of:

artist_name-song_title-source-codec-year-group.ext

I want to rename them to:

Artist Name - Song Title.ext

The purpose of this is for use with Plex or Kodi. So far I've come up with this:

{fn.replaceAll("-", replacement = " - ").replaceAll("_", replacement = " ").upperInitial()}

Which will rename the file to:

Artist Name - Song Title - Source - Codec - Year - Group.ext

My questions are is it possible to wildcard a character in a pattern match? Or is there a good way for me to after the second " - " character appears in the filename to trim or drop all remaining text in the file name?

Thanks for any help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Music Video Renaming Based On File Name, please help - new user

Post by kim »

try {fn.split(/-/)[0]+' - '+fn.split(/-/)[1]}
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Music Video Renaming Based On File Name, please help - new user

Post by kim »

or in one go
{(fn.replaceAll('_',' ').split(/-/)[0]+' - '+fn.replaceAll('_',' ').split(/-/)[1]).upperInitial()}
User avatar
rednoah
The Source
Posts: 22990
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Music Video Renaming Based On File Name, please help - new user

Post by rednoah »

Indeed, if "-" appears only as separator, but not as part of the artist/title, then you can just split and take.

e.g.

Code: Select all

fn.split(/-/).take(2).join('-')
test case:

Code: Select all

'artist_name-song_title-source-codec-year'.split(/-/).take(2).join('-')
:idea: Please read the FAQ and How to Request Help.
RandomNinjaAtk
Posts: 2
Joined: 29 Jun 2017, 21:38

Re: Music Video Renaming Based On File Name, please help - new user

Post by RandomNinjaAtk »

Thanks for all the suggestions, I'll give them a shot!
Post Reply