Home User Forums SongKong Music Tagger Jaikoz Music Tagger Albunack Music Service
Showing posts with label filename. Show all posts
Showing posts with label filename. Show all posts

Thursday, 14 January 2016

An even easier way to shorten audio filenames with Functions

In the previous post I showed you how you can reduce the length of the filename so less than the maximum allowed. This can be a particular problem for classical music and be useful for better compatibility with other applications.

But one problem with this approach is you have to check the length of the field first and then only substring it if its too long, because if it is not long enough substring() would give an error. This can make more complex rename masks a little unwieldy.

i.e.
This code checks the album field length is greater than 100 and if it then substrings it otherwise it just outputs the value as is.

(album.length>100 ? album.substring(0,100):album)

1. So lets make this simpler by creating a function, open up your rename mask for editing and then select the Add button at the bottom of window,




2. Now create the following function as shown in the window, then select OK.

function substring(value,length){
     return value.length > length ? value.substring(0, length)  : value;
 }




 3. Now we can use this new function in any rename mask, we simply put substring() around any value we want to limit the length of, and no longer need to check the length first.

i.e. here we use substring on albumartist, artist, title and year fields.

ifnotempty(substring(albumartist,50),' - ')
+ ifnotempty(substring(album,50),' ')
+ '(' + substring(year,4) +')/'
+ ifnotempty(pad(trackno,2),' - ')
+ ifnotempty(substring(artist,50),' - ')
+ substring(title, 50)





4. You can also use substring to simply truncate the total replaceable path by wrapping substring() around whatever you want to truncate.

i.e convert this mask:

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


to be no longer than 200 characters with:

substring(
(ifnotempty2(albumartist,artist,' - ')
+ ifnotempty(album,' - ')
+ ifmultidisc(ifnotempty(pad(discno,2),' - '))
+ ifnotempty(pad(trackno,2),' - ')
+ title),200)








Thursday, 30 January 2014

The Components of the Filename

There is sometimes some confusion about how SongKong views filenames so I'm going to try and explain with an example. The starting point of SongKong is to select a folder to process - we shall call this the Root Folder. Then SongKong tries to guess what part of the folder path contains metadata such as Artist name or Album name and which part does not contain metadata. It then splits the folder path into Base Folder and Sub Folder with the Sub Folder containing the part matching the metadata and the Base Folder not.

Then as files within the root folder are loaded into SongKong they will all have the same Root Folder. They will all have the same starting Sub Folder but it will have any additional subfolders appended to it. The last part of the path is termed the Filename.

The root/sub folder divide is important because if your songs are renamed from metadata only the sub folder part is renamed from your metadata in contrast if your songs are moved only the root folder is changed.

Now an example:

Root Folder:/Music/Blur
Base Folder:/Music
Sub Folder   :Blur

Files within /Music/Blur such as

/Music/Blur/ParkLife/Girl & Boys.mp3

would be split as:


Base Folder:/Music
Sub Folder  :Blur/ParkLife
Filename      :Girl & Boys.mp3

Hope that clarifies things.
Jthink blog Jthink Facebook page google_plus Jthink YouTube channel Email Paul at Jthink Subscribe to Weekly Newsletter