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.
Music Video Renaming Based On File Name, please help - new user
-
- Posts: 2
- Joined: 29 Jun 2017, 21:38
Re: Music Video Renaming Based On File Name, please help - new user
try {fn.split(/-/)[0]+' - '+fn.split(/-/)[1]}
Re: Music Video Renaming Based On File Name, please help - new user
or in one go
{(fn.replaceAll('_',' ').split(/-/)[0]+' - '+fn.replaceAll('_',' ').split(/-/)[1]).upperInitial()}
{(fn.replaceAll('_',' ').split(/-/)[0]+' - '+fn.replaceAll('_',' ').split(/-/)[1]).upperInitial()}
Re: Music Video Renaming Based On File Name, please help - new user
Indeed, if "-" appears only as separator, but not as part of the artist/title, then you can just split and take.
e.g.
test case:
e.g.
Code: Select all
fn.split(/-/).take(2).join('-')
Code: Select all
'artist_name-song_title-source-codec-year'.split(/-/).take(2).join('-')
-
- Posts: 2
- Joined: 29 Jun 2017, 21:38
Re: Music Video Renaming Based On File Name, please help - new user
Thanks for all the suggestions, I'll give them a shot!