[Logo] Jaikoz and SongKong Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
File and Folder renaming masks examples.  XML
Forum Index -> General
Author Message
greengeek

Pro
[Avatar]

Joined: 18/09/2007 02:50:48
Messages: 435
Offline

Thought it would be nice to make a topic to see how people use the new renaming files and folders options as well as to post theirs to help those that might be having a hard time with the code.

Here is mine. Folder rename:

Code:
 (albumartist.length>0  ? albumartist + folderseparator :(artist.length>0 ? artist + folderseparator : '')) + (year.length>0  ? '(' + year + ') ' : '') + album + (mbreleasecountry.length>0  ? ' (' + mbreleasecountry + ') ' : '')+ (disctotal > 1 ? ' (disc ' + discno + ')' : '')
 


and for various artists:

Code:
 (albumartist.length>0  ? albumartist + folderseparator : 'Various Artists' + folderseparator)  + (year.length>0  ? '(' + year + ') ' : '') + album + (mbreleasecountry.length>0  ? ' (' + mbreleasecountry + ') ' : '')+ (disctotal > 1 ? ' (disc ' + discno + ')' : '')
 


I keep my file names a bit more simple on both:

Code:
 (trackno.length>0 ? trackno + ' - ' :'')  + title
 


It ends up giving me something like this as an output:


10,000 Maniacs\(2004) Campfire Songs The Popular, Obscure & Unknown Recordings (US) (disc 1)\01 - Planned Obsolescence.mp3
 


Would be great to see some other examples of how people are using this new feature!

KevinBluemel.com
Contemporary Instrumental Musician and Composer. Stop by to listen, watch videos, and get free downloads of songs and sheet music.
[WWW]
paultaylor

Pro
[Avatar]

Joined: 21/08/2006 09:21:27
Messages: 7359
Online

Great idea, I dont have a full example but just want to bring to your attention you can now use regular expression syntax in your mask

i.e this silly example changes any instance of the word 'Boy' in the album field to 'Girl'.

Code:
 album.replace(/Boy/g,'Girl')
 

thanks Paul (Administrator)
greengeek

Pro
[Avatar]

Joined: 18/09/2007 02:50:48
Messages: 435
Offline

Awesome! I noticed that all the sources don't have a standard for release countries. I wouldn't mind using a replace so that everything uses a country code or abbreviation instead of spelling out the full country which some releases do. I may have to try this on some of the more common country names, though it may look scary on how long the mask will be time I get done adding this to it.

KevinBluemel.com
Contemporary Instrumental Musician and Composer. Stop by to listen, watch videos, and get free downloads of songs and sheet music.
[WWW]
paultaylor

Pro
[Avatar]

Joined: 21/08/2006 09:21:27
Messages: 7359
Online

hmm. we do actually receive the country code normally (i,e CZ versus Czech Republic) but we convert to the country, we only display the country code if we cant map the code to the country.

Maybe displaying country code instead of country should be an option in Jaikoz.

thanks Paul (Administrator)
greengeek

Pro
[Avatar]

Joined: 18/09/2007 02:50:48
Messages: 435
Offline

paultaylor wrote:
hmm. we do actually receive the country code normally (i,e CZ versus Czech Republic) but we convert to the country, we only display the country code if we cant map the code to the country.

Maybe displaying country code instead of country should be an option in Jaikoz. 


That would rock if there was some type of feature to do this! Currently I am sorting by release country then finding any of the long spelled out names and manually replacing them with the country code. Using the same country codes that musicbrainz uses listed on http://wiki.musicbrainz.org/Release_Country Fairly time consuming to locate which are spelled out and doing a manual find and replace.

KevinBluemel.com
Contemporary Instrumental Musician and Composer. Stop by to listen, watch videos, and get free downloads of songs and sheet music.
[WWW]
greengeek

Pro
[Avatar]

Joined: 18/09/2007 02:50:48
Messages: 435
Offline

moved this post to wishlist

KevinBluemel.com
Contemporary Instrumental Musician and Composer. Stop by to listen, watch videos, and get free downloads of songs and sheet music.
[WWW]
astroid0

Enthusiast

Joined: 20/12/2008 12:35:21
Messages: 16
Offline

Is it possible to do something along these lines:

IF mbreleasecountry IS NOT EQUAL TO 'U.S.A' THEN + '('mbreleasecountry')'

I tried adjusting the examples here to make it work, but I thought I would just ask rather than fiddling with something for hours that may or may not work.

Thanks for those examples btw! Aside from the country code difference that is exactly what I was trying to make, and I was having a bit of trouble after the update.
paultaylor

Pro
[Avatar]

Joined: 21/08/2006 09:21:27
Messages: 7359
Online

Yes just do

Code:
 (mbreleasecountry!='US' ? mbreleasecountry :'')
 

thanks Paul (Administrator)
seth.feinberg

Pro

Joined: 17/12/2011 20:48:04
Messages: 42
Offline

Hey all! Just chiming in cause I find this aspect of Jaikoz to be one of the most useful and interesting and this thread to have a ton of useful potential:

Folder Rename Mask:
Code:
(albumartist.length>0  ? albumartist +folderseparator :(artist.length>0 ? artist + folderseparator : '')) + '(' + (originalyear.length>0 ? originalyear.substring(0,4) : (year.length>0 ? year.substring(0,4) : '')) + ') ' + (artist.length>0 ? artist : (albumartist.length>0 ? albumartist : '')) + ' - ' + album


Compilation Rename Mask:
Code:
(artist.length>0  ? artist +folderseparator :(albumartist.length>0 ? albumartist + folderseparator : '')) + '(' + (originalyear.length>0 ? originalyear.substring(0,4) : (year.length>0 ? year.substring(0,4) : '')) + ') ' + (albumartist.length>0 ? albumartist : (artist.length>0 ? artist : '')) + ' - ' + album


Some comments on my folder renaming: They are mostly the same with the main difference that I use opposite values of Albumartist and Artist for non-compilation and compilation. The reasons for my decisions all come down to my organizational decision to organize my collection primarily by artist. I'll explain the finer decisions through examples. 2Pac released an album early in his career as Makaveli. I want all of 2Pac's albums to be under one folder called 2Pac so I fudge the metadata for this album by putting "Makaveli" under the Artist column and "2Pac" for Albumartist (I do the same for all of Diddy's names - Puff Daddy, P Diddy, for example). Conversely, I don't want a "Various Artists" folder with a bunch of random artists/albums inside (I would never wish to listen to the Forest Gump soundtrack by itself for example). My renaming convention will mean that I will have all of 2Pacs albums organized (hopefully) by year of release and properly named with the artist if a non-compilation (Makaveli) and albumartist if a compilation (Various Artists). I wonder if I will run into issues with Single Artists Compilations but haven't yet and think it would be a rare occurrence anyways. I think this yields the best compromise between artist organization and accurate folder naming but am curious what others think.

Oh and I've also used originalyear if available and substring (thanks paul!) in order to keep my metadata as accurate as possible (correct year of rerelease and full date if available) while only displaying a 4 digit year for the folder scheme.

For my files, its a bit simpler but I wanted enough info so that I could find the files home if it gets accidentally moved...

File Rename Mask:
Code:
(artist.length>0  ? artist +' - ' :(albumartist.length>0 ? albumartist + ' - ' : '')) + (album.length>0 ? album + ' - ' :'') + (disctotal>1 ? discno + ' - ': '') + (trackno.length>0 ? trackno + ' - ' :'')  + title


Compilation Rename Mask:
Code:
(artist.length>0  ? artist +'-' :(albumartist.length>0 ? albumartist + ' - ' : '')) + (album.length>0 ? album + ' - ' :'') + (disctotal>1 ? discno + ' - ': '') + (trackno.length>0 ? trackno + ' - ' :'')  + title


I believe these are exactly the same with the only thing of note being that I append a disc number to the track number if the release has more than one total discs.

After writing this, I'm wondering if perhaps I should have the same renaming convention for folders, but switch the values for artist and albumartist for my non compilations (for example have 2Pac be the artist and Makaveli be the Albumartist).

Also I'm trying to figure out how to use the "Replace()" method to replace artists and songs with a "/" to a "-" I don't like that I either have AC/DC's albums in a subfolder "DC" inside folder "AC" or I have my metadata incorrectly labelled as AC-DC. If I use File and Folder Renaming -> Replace 'From' Character with 'To' Character I end up with a long folder named AC-DC-(1979) - Highway to Hell

anybody have any thoughts on these 2 points?
seth.feinberg

Pro

Joined: 17/12/2011 20:48:04
Messages: 42
Offline

On retrospection, I've decided to do what I detailed in italics at the end. That is: change how I use Albumartist and artist in Jaikoz (i.e. 2Pac is the artist and Makaveli is the Albumartist)
evilnick



Joined: 10/05/2012 05:43:42
Messages: 2
Offline

My probably fairly bad code (that I liberally borrowed from the other examples here) is:

Rename Folder
Code:
(albumartist.length>0  ? albumartist +folderseparator :(artist.length>0 ? artist + folderseparator : '')) + (year.length>0 ? year.substring(0,4) : '') + ' - ' + album + (disctotal > 1 ? ' CD' + discno:'')


Rename Files
Code:
(trackno.length>0 ? trackno + ' - ' :'')  + (title.length>0 ? title + ' - ' :'') + (artist.length>0 ? artist :'')


The thought-process being that I wanted something that would work for both single-artist and V/A albums (I'm incredibly anal about having valid AlbumArtist tags), splits out albums that are on more than one CD, and has the Artist added to the filename so that any media player that only looks at filenames can still be searched.
tmcneill71



Joined: 03/06/2012 21:29:15
Messages: 6
Offline

Guys, I'm very new to Jaikoz and was having some trouble with the default masks. I just wanted to write to say "Thanks!" for this thread. It helped me out a bunch and also assisted me in understanding just how these work. Also, I wanted to know if seth.feinberg found a way to deal with the AC/DC issue, it's a definite prob for me too.

Anyway, thanks again!
paultaylor

Pro
[Avatar]

Joined: 21/08/2006 09:21:27
Messages: 7359
Online

Please see http://www.jthink.net/jaikozforum/posts/list/6697.page for a way to make this all easier

thanks Paul (Administrator)
seth.feinberg

Pro

Joined: 17/12/2011 20:48:04
Messages: 42
Offline

Never considered including functions so perhaps these ridiculously long masks could be done much much easier, but I've significantly retooled my masks since the last time I posted and thought I'd repaste them now.

Folder Rename Mask: Code:
(artist.length>0 ? whichartist = artist : (albumartist.length>0 ? whichartist = albumartist : whichartist = 'noartist'));
 artistmod = whichartist;
 while (artistmod.charAt(artistmod.length-1) == ".") {artistmod = artistmod.substring(0,(artistmod.length-1));};
 albummod = album;
 while (albummod.charAt(albummod.length-1) == "." ) {albummod = albummod.substring(0,(albummod.length-1));};
 (artistmod + folderseparator) + (originalyear.length>0 ? '(' + originalyear.substring(0,4) + ') ' : (year.length>0 ? '(' + year.substring(0,4) + ') ' : '')) + (album.length>0 ? whichartist : artistmod) + (album.length>0 && (albumartist.length>0 || artist.length>0) ? ' - ' : '') + (albummod)

File Rename Mask: Code:
PersonalMax=190;
 Fills=12; //2 slash's, 6 for year, 3 for seperation of artist/album
 (albumartist.length>0 ? WhichArtist = albumartist : (artist.length>0 ? WhichArtist = artist : WhichArtist = 'noartist'));
 (artist.length>0 ? RWhichArtist = artist : (albumartist.length>0 ? RWhichArtist = albumartist : RWhichArtist = 'noartist'));
 PreTitle=RWhichArtist.length + WhichArtist.length + album.length + Fills;
 ForFileName=PersonalMax - PreTitle;
 FullSum=title.length + album.length + WhichArtist.length + 13;
 NoAlbumSum=title.length + WhichArtist.length + 10;
 TitleTrackSum=title.length + 7;
 (TitleTrackSum>ForFileName ? (
 	WhatToCut=TitleTrackSum-ForFileName+3,
 	NewAlbum='',
 	NewArtist='',
 	NewTitle=title.substring(0,(title.length-WhatToCut)) + '...'
 	) : (
 		NoAlbumSum>ForFileName ? (
 		WhatToCut=NoAlbumSum-ForFileName+3,
 		NewAlbum='',
 		NewArtist=WhichArtist.substring(0,(WhichArtist.length-WhatToCut)) + '...',
 		NewTitle=title + ' - '
 		) : (
 			FullSum>ForFileName ? (
 			WhatToCut=FullSum-ForFileName+3,
 			NewAlbum=album.substring(0,(album.length-WhatToCut)) + '...',
 			NewArtist=WhichArtist + ' - ',
 			NewTitle=title + ' - '
 			) : (
 				WhatToCut='',
 				NewAlbum=album,
 				NewArtist=WhichArtist + ' - ',
 				NewTitle=title + ' - ')
 		)
 	)
 );
 (disctotal>1 ? discno + '-': '') + (trackno.length>0 ? trackno + ' - ': '') + (title.length>0 ? NewTitle : '') + NewArtist + (album.length>0 ? NewAlbum : '')


Compilation Folder Rename Mask: Code:
(albumartist.length>0 ? whichartist = albumartist : (artist.length>0 ? whichartist = artist : whichartist = 'noartist'));
 artistmod = whichartist;
 while (artistmod.charAt(artistmod.length-1) == ".") {artistmod = artistmod.substring(0,(artistmod.length-1));};
 albummod = album;
 while (albummod.charAt(albummod.length-1) == "." ) {albummod = albummod.substring(0,(albummod.length-1));};
 (artistmod + folderseparator) + (year.length>0 ? '(' + year.substring(0,4) + ') ' : (originalyear.length>0 ? '(' + originalyear.substring(0,4) + ') ' : '')) + (album.length>0 ? whichartist : artistmod) + (album.length>0 && (albumartist.length>0 || artist.length>0) ? ' - ' : '') + (albummod)


Compilation File Rename Mask: Code:
PersonalMax=190;
 Fills=12; //2 slash's, 6 for year, 3 for seperation of artist/album
 (artist.length>0 ? WhichArtist = artist : (albumartist.length>0 ? WhichArtist = albumartist : WhichArtist = 'noartist'));
 (albumartist.length>0 ? RWhichArtist = albumartist : (albumartist.length>0 ? RWhichArtist = albumartist : RWhichArtist = 'noartist'));
 PreTitle=2*RWhichArtist.length + album.length + Fills;
 ForFileName=PersonalMax - PreTitle;
 FullSum=title.length + album.length + WhichArtist.length + 13;
 NoAlbumSum=title.length + WhichArtist.length + 10;
 TitleTrackSum=title.length + 7;
 (TitleTrackSum>ForFileName ? (
 	WhatToCut=TitleTrackSum-ForFileName+3,
 	NewAlbum='',
 	NewArtist='',
 	NewTitle=title.substring(0,(title.length-WhatToCut)) + '...'
 	) : (
 		NoAlbumSum>ForFileName ? (
 		WhatToCut=NoAlbumSum-ForFileName+3,
 		NewAlbum='',
 		NewArtist=WhichArtist.substring(0,(WhichArtist.length-WhatToCut)) + '...',
 		NewTitle=title + ' - '
 		) : (
 			FullSum>ForFileName ? (
 			WhatToCut=FullSum-ForFileName+3,
 			NewAlbum=album.substring(0,(album.length-WhatToCut)) + '...',
 			NewArtist=WhichArtist + ' - ',
 			NewTitle=title + ' - '
 			) : (
 				WhatToCut='',
 				NewAlbum=album,
 				NewArtist=WhichArtist + ' - ',
 				NewTitle=title + ' - ')
 		)
 	)
 );
 (disctotal>1 ? discno + '-': '') + (trackno.length>0 ? trackno + ' - ': '') + (title.length>0 ? NewTitle : '') + NewArtist + (album.length>0 ? NewAlbum : '')


Essentially I fix my music on a Mac, store it on a Linux box and access it on Mac OSX and PC's so interoperability was paramount. The Folder rename masks make sure that a folder name never ends in a period, whcih causes issues on PC (its autofixed if you tag them with Jaikoz ON a PC, but not when they are created on a Mac). The File rename masks make sure that the resulting file doesn't become too long to display on PC's by first removing/shortening the album part of the filename (which comes last), then the artist/albumartist field (which is 2nd to last) and then shortens the title depending on how much the file needs to be shortened. It's likely this could've been done easier with functions but I didn't realize that functionality until I went here to post my new masks and, frankly, am not that great of a coder to begin with. Anyways, hope this helps somebody out, feel free to ask me any questions.
n1ete

Enthusiast

Joined: 17/02/2016 16:53:34
Messages: 11
Offline

hello there,
sorry for necrobumping this old one here but i used my advanced copy & paste skills to try these examples out on a small bunch of my audio files.
unfortunately songKong just give me and invalid mask error.
my coding experience is = zero
so i would appreciate some help here....

i like the idea of split the folder structure into singles and full albums...or i imagine an structure automatically sorted by genres could also be nice

i also think this post was anyways a good idea to get creative with good sorting solutions for large music libraries like i have (160 000 files) and of course for education purposes

so please pop out your custom file/folder/compilation rename masks and share them with us!
thank you so much!
...
...
...
i have just one more question for now...
would it be possible to add an "label" in folder structure?


edit says: maybee it would be better to start a new thread? i would love to start one and make it sticky-worthy
Tagger Joe

Pro
[Avatar]

Joined: 25/11/2010 22:26:53
Messages: 23
Location: Munich Music Museum
Offline

After a few Years of no tagging, because of the "new" way of telling the Program what to do, again i give it a try.

Does Folder rename recognize the album as a compilation, because the Compilation Field is marked? Or have i go to preverences all the time?

Then i want Compilations Renamed in one Folder with the Albumname and the Files in it renamed in Tracknumber - Artist - Titel, why ist it even in 2018 with all the computers and programs not possible to tell the program this in a simple way???

Does progtrammers need it complicated?

Again i have no clue of this language, i tried to change something in Prefs and i endet up in

BoyundefinedU2" - 02 - Twilight wtf

"tag my day"
Tagger Joe

Pro
[Avatar]

Joined: 25/11/2010 22:26:53
Messages: 23
Location: Munich Music Museum
Offline

So i changed it to:

function pad(number, length) {
if (number == '') { return '';}
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}


function ifnotempty(value,sep){
return value.length > 0 ? value + sep : '';
}

function ifnotempty2(value1,sep){
return value1.length > 0 ? value1 + sep :'' ;
}

ifnotempty2(album,' - ') + ifnotempty(pad(trackno,2),' - ') + ifnotempty(artist,' - ') + title 


But now i have an extra Folder with only the cd number as the name

"tag my day"
paultaylor

Pro
[Avatar]

Joined: 21/08/2006 09:21:27
Messages: 7359
Online

Remember in Jaikoz there are separate masks and tasks for renaming the filename, and renaming the subfolders. So like a filename mask and hence wil have no effect on subfolders, and will only be called when you do Rename Filename from Metadata. Subfolders will change when you do Rename SubFolder from Metadata.

thanks Paul (Administrator)
laurie_lewis



Joined: 30/04/2018 21:10:27
Messages: 6
Offline

I saw that you could you regular expressions via the example quoted.

Code:
album.replace(/Boy/g,'Girl')


but I was wondering how you might put that into a function. I have a regular expression that I found

Code:
find /^(?i)(The)\s(.*)$/ replace with "$2, $1"


This takes "The" found at the beginning of a string and moves it to the end of the string as ", The". It was my intention to use this for Artists & albums. I was previously playing with albumartistsort, artist sort, albumsort but at times I get inappropriate results, empty fields, split names with commas everywhere etc.

So I was thinking that a regular expression would be a more consistent approach, especially inside a function. I could then use something like:

Code:
 ifnotempty2(suffixthe(albumartist).substring(0,1),suffixthe(artist).substring(0,1),'/')
 + ifnotempty2(suffixthe(albumartist),suffixthe(artist),'/')
 + ifnotempty(suffixthe(album),'/')
 + ifmultidisc(ifnotempty(pad(discno,2),' - '))
 + ifnotempty(pad(trackno,2),' - ')
 + title
 


I have no idea if suffixthe(albumartist).substring(0,1) would work - just thinking out loud. Now back to read this thread again to look at removing those pesky .. at the end of names.

Ok, while I am at it. All those albums you have with "The Best Of..." - Does anyone have a naming mask that removes the ... and replaces it with the "The Best/Most/Greatest Hits of Album Artist?

Thanks

Laurie
laurie_lewis



Joined: 30/04/2018 21:10:27
Messages: 6
Offline

I wasn't able to get my suffixThe function working using regex but I did with this.

Code:
 function suffixThe(value) {
 if(value.startsWith("The "))
    {
       value = value.substring(4) + ", The"
       return value;
    }
    else
    {
       return value;
    }
 }
 


I have begun to use it with my naming mask

ifnotempty2(suffixThe(albumartist).substring(0,1),suffixThe(artist).substring(0,1),'/')
+ ifnotempty2(suffixThe(albumartist),suffixThe(artist),'/')
+ ifnotempty((year.length>4 ? year.substring(0,4):year),' - ')
+ ifnotempty(suffixThe(album),'/')
+ ifmultidisc(ifnotempty(pad(discno,2),' - '))
+ ifnotempty(pad(trackno,2),' - ')
+ title
 


Laurie
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.6 © JForum Team