SongKong Jaikoz

SongKong and Jaikoz Music Tagger Community Forum

Mask Editing - Smart Length Limit/Truncate

@paultaylor Can you please guide me through properly setting up maximum character limits with the Preferences:Filename Masks:Masks: section?

Enable Maximum File Path Length

When renaming or moving files SongKong respects the file system limits set by the operating system, most notably Windows set a limit of 260 characters for the complete path. But some legacy applications may impose short maximum lengths, or you may use SongKong with one operating system but want the files to be compatible with another.
The Maximum File Path Length option provides an easy way to set a maximum filepath length, if the file name is too long the file name part will be truncated accordingly.

:star2: A more powerful approach is modify your rename mask to set different maximum lengths for different parts of their mask using the inbuilt JavaScript substring function. :star2:

I’ve been trying to figure out my masking and I almost have it perfect, but I have song names which are too long for the ~260 character limit.

I’ve been following the guide here but I had some questions…

Please help me limit the filename character limit while editing the Preferences:Filename Masks: in SongKong mask edit box utilizing Java substring in conjunction with specific tag categories/masks.

I definitely want to avoid the destructive Fix Songs:File Naming:Enable Maximum File Path Length:
If possible, looking for assistance with #1 and #2 below; and if not, then #3 - or all! :joystick:

  1. + ifnotempty(title,'; ') - to limit length of title

  2. Do the above but so that it doesn’t cut words off in the middle when limit is encountered (e.g. Long_File_Na…flac)
    – I really prefer this option… Would there be a method in java for something specific like this?

and/or

  1. to limit length for all selected masks in Preferences:Filename Masks:Masks: mask rename rule

Thank you for your time!

Would be useful if you could post your mask and an example of a filename that is too long.

Also worth noting that although there is a 260 character limit in WIndows Explorer, Windows itself can handle longer filenames.

Rename Failed from /home/aj/Music/Base/Bedřich Smetana; Prodaná nevěsta - Zdeněk Košler; Česká filharmonie; Pražský filharmonický sbor - The Bartered Bride Act I, Scene II. Kdybych se co takového o tobě dověděla (Should I ever happen to learn)/Track 3 of 15; Kdybych se co takového o tobě dověděla (Should I ever happen to learn).flac

to

/home/aj/Music/Base/Košler; Česká filharmonie; Pražský filharmonický sbor - The Bartered Bride- Act I, Scene II. Kdybych se co takového o tobě dověděla (Should I ever happen to learn); Track 3 of 15; Kdybych se co takového o tobě dověděla (Should I ever happen to learn).flac

Failure and error occur also when the program tried to move the selected file… naturally.

As far as posting example of my mask… I need to find out how to set up the mask so it cuts off some of a title, but not so much as to make it unreadable.
EXAMPLE:
You see the duplicated (Should I ever happen to learn) part… I prefer to remove just those kinds of duplicate parts in all songs if they exist in the filename. However I don’t know the most efficient [and safe] way to code this in Javascript. I am not proficient in that language.

I do know that if I remove masks just to make these few filenames work, then I will not be accomplishing what I want to do - because the modified mask will now affect all the other filenames which are not too long.

FOR INSTANCE: I know an option is to get rid of “Movement” because the “Title” seems to be showing the same thing… but “Movementisn’t always masked the same as the “Title” in all of my files. Just seems to be in these few cases.

This seems to be a very isolated incident with just a few matches and do not want to modify golbal rules just to make it work with my naming scheme - I would also prefer to avoid making another mask set to handle this kind of thing if possible.

I want it set up like this with file/folder structure looking like:
[Folder]: Composer; MBWork - Conductor; Orchestra; Choir - Title ‘/’
[Filename]: Track ‘of’ TrackTotal; Movement
—OR, in your example style—
[Folder]: Bono, The Edge; workName - Conductor; The Edge; Voice Choir - Twilight ‘/’
[Filename]: Track 2 of 11; movement

ifnotempty(composer,'; ')
+ ifnotempty(mbwork,' - ')
+ ifnotempty(conductor,'; ')
+ ifnotempty(orchestra,'; ')
+ ifnotempty(choir,' - ')
+ ifnotempty(title,'/')
            + 'Track '
 + ifnotempty(trackno,' of ')
 + ifnotempty(tracktotal,'; ')
 + ifnotempty(movement,'')

Please let me know what would happen if I added + titlesort in there, before or after + ifnotempty(title,'; ') ?

Before I consider this any further two things stand out.

  1. You want to organize into folders organized by works rather than album, now I totally understand you may want to play music based on works rather than albums, however I wouldn’t recommend splitting into albums into works. This makes it much harder for tools like SongKong to match to the correct album, and is unnecessary assuming you are going to use the metadata to rather than folder structure to play your music.
  2. You are putting alot of information into your folder/file name. If you are going to restrict yourself to 260 characters i think you are going to hit thhis limit alot, it maybe better to settle on a less verbose naming.

Thanks @paultaylor

Really what I wanted to do was have my folders not be a mess. So I wanted to organize it so that the folders are created based on who composed it, which orchestra or choir(if any), and the MBwork name. This is so I know exactly which work/movement comes next when navigating the folders. I only put the MBWork name first because the composer name kept being duplicated in the folder names -which was annoying.

Is it possible to put a variable in a mask so that it doesn’t insert something twice?

Does that make sense?

I’m all for using a prebuilt mask setup if you have a good one and want to share, but with my limited knowledge of JavaScript, I’m doing my best to set myself up.

I would prefer to not switch between masks every time I encounter a rename error like this.

Please let me know if I can provide any further information to facilitate solving this problem.

Thanks!

Firstly, just want to reiterate my first point that you seem to have ignored. Ideally songs should be organized into folders that represent albums, some reasons for this are:

  1. Your songs can only be organized in one folder structure at a time, but with good metadata can be viewed in different ways. So how you navigate the songs for playing should not really determine folder structure, since using folder structure should only be used when metadata is missing.
  2. Much easier for tools such as SongKong to correctly identify the correct album (most songs are available on multiple albums but customers want to match to the album they have)
  3. Many players read artwork from folders instead of the music files themselves, if the folder structure is not album based then no logical place to store album artwork.

That being said, if you want to go ahead with organizing by composer then there is a serious issue with your mask, you have title in the folder structure. This is the song title and therefore will be different for every music file and therefore you will create a series of single song folders, the title should be moved after the ‘/’

To investigate this bit about composer being added twice you would need to send me your support files, the composer is not usually added to the work name in MusicBrainz database.

@paultaylor I wasn’t ignoring anything, I just didn’t know what to do with that suggestion because all it did was point out something I could maybe try - but only after interrupting any progress I may have made with my original request.

Re-stated my original question because I seem to keep receiving recommendations and suggested workflow patterns in lieu of answers to my questions and suggestions on this program.

I’m sure it goes without saying, but I will anyway: users of your product are your most valuable Quality Assurance asset for fairly obvious reasons. I just want to help make this program into something on which more people will want to spend their hard-earned cash.

I understand that you have your own way of masking/re-naming things on your computer/device, and I also understand others will have their own preference.

Thank you for the recommendations; still wanting to find out if it’s possible to set up conditional functions for truncating length - as well as a sorting function which can organize the tracks by movement (I want to keep movement’s position in the end of the mask because Classical) - It would be even better if it could organize track numbers and disc numbers secondary to the movement.
e.g.
... Allegro vivace - Track 1 - Disc 1
... Largo maestose - Track 2 - Disc 2
... Finale. Allegro non troppo ma energico - Track 4 - Disc 3
in order.

After hours of messing around with this and teaching myself many things, I managed to make my mask do mostly what I originally wanted:

Only problem is the extra hyphens at the end of the filename. I have been able to stay away from single-file folder creation so far…

In searching through my mask while comparing the location of the hypens and name content, I found something with which I might need help…


Using the mask in the picture above, I always seem to get two hyphens before the movement which is at the end of the filename. Can you advise on a way to avoid these two hyphens while keeping the function alive? I’ve tried adding parentheticals with the concatenated ";" or "-" to no avail.

Thanks.

I just wanted to make it clear to you that your way of doing things is likely to cause you problems but of course it is your own choice.

Because the mask you are now using has the title after the ‘/’ and this is not the same as the mask you posted earlier with title before ‘/’, I was just trying to help you on the basis of what you posted.

I am not clear what you want to do, something like truncate title but only if total length is greater than x ?

Here is simple example that shortens title to 20 if length of title & composer & album is greater than 100, but doesn’t shorten if isn’t

(title.length + composer.length + album.length > 100 ? substring(title, 20):title)

But seems it might be quite complex to extend this in a way that would work for everything.

SongKong renames the file according to your mask, the tool that you use to view the files will usually sort them alphabetically, that is why you would usually put trackno or movementno before title. If you are viewing the songs using metadata then it should sort correctly by the trackno/movementno metadata but if you are just viewing by filename then it will usually list them alphabetically

The double hyphens occur if you have no value for mbwork or movement, this is because the line

(title.length>245 ? title.substring(0,245):title) + ' - '

will always put a hyphen after the title, and the line

(mbwork.length > 190 ? mbwork.substring(0,190):mbwork,' -')

will put a hyphen if mbwork is not set or shorter than 190, you don’t need a hyphen after title unless you have either mbwork or movement so I think you need to replace the last three lines with

+(substring(title, 245))
+(mbwork.length > 0 ? ' - ' + substring(mbwork, 190):'')
+(movement.length > 0 ? ' - ' + substring(movement, 75):'')

(The SongKong defined substring function shortens the text if too long but does nothing and doesn’t complain if not too long)

Thanks.

The reason I posted my issue is because I have a lot of music which can be considered as stories.
I wanted to make sure that the listener would always be able to listen to the next movement of the story composed by the composer. As I’m sure our composer also meant for their audience.

These songs have been renamed via the mask, but some seem to lose their place in the sequence after the rename occurs. This is why I attempted to place the title - even attempting titlesort - before Track/Movement

For the below examples, “Andante”, Song 3, needs to be shown as the second song in the same folder/work. Is there an unlisted tracksort function that I’m missing?
example, before rename:
Song 1 = Overture/Intro/ = Track 1
Song 2 = Andante = Track 2
Song 3 = Allegro vivace = Track 3
example, after rename:
Song 1 = Overture/Intro/ = Track 1
Song 2 = Allegro vivace = Track 3
Song 3 = Andante = Track 2

I want to avoid my rename mask disrupting/rearranging the sequence of songs. I want to keep the story structure so that when listening, my player auto-plays the correct next song. I placed the track and movement at the end because of this problem of songs not following correct sequence.

You are right, my masks need work and I am tweaking it and finding new things every hour. I hope this helps.

Thank you for your help.

When you say the order has changed, what are you viewing the songs with, in what application are they shown in the wrong order, perhaps post a screenshot to make it clearer.

This is essentially what I’m dealing with. Notice the Act # and Scene # are out of order. I removed the padded trackno function because of the same type of issue with track numbers being out of order.

This issue exists even after navigating to the file in file manager and clicking the Name column to sort in ascending order.

Act I, Scene V should follow Act I, Scene IV and so forth… Currently it looks reversed; which is why I asked about any potential mask functions for sorting tracks and Acts/Scenes.
I definitely don’t want the player to play Act I, Scene V before I hear it play
Act I, Scene IV. Same goes for the track numbers, I want to play the songs in order as they were arranged to be played by the composer or on a record.

What is this a screenshot from ?

Screenshot from file manager.

Perhaps this is a better view… Do you see where the Name column is sorted for alphabetical descending order. Still though, Act III is before Act II. It looks like I managed to correct the Scenes being out of order, but still I want to ensure my music player plays the songs in correct sequence.

Yes like I said it’s alphabetical because Act III comes before Act II because I comes before ,.

FileManager is not a music player it is just looking at the filename not the metadata, do you understand the difference between filename and metadata within file ?

Why don’t you use a music player to play your music, this would likely sort by movementno or at least trackno

This is the naming scheme or format I’m looking to use. See how Act 1,2,3 and their Scenes follow one-another in increasing order?

Just clarifying… So are you saying III (3) comes before II (2)…? Is this common to every operating system? This is getting weirder by the minute.

Playing the songs in VLC. It sorts the Acts and Scenes correctly, but still the ‘Overture’ is at the end of the playlist due to alphabetical sorting of Name column inside the player. An overture is the instrumental introduction that precedes the composition. It should be played first, always.

No I’m saying III comes before II, but can’t you see that on your last screenshot you have Act 1, Act 2, and in alphanumeric sorting it knows the order is 1,2,3…but in the previous screenshot using are using roman numerals, they are different things.

I can sort the music in VLC by track number which places the “Overture” at the front, but then I would run into a problem if the track doesn’t have a trackno associated with it for whatever reason.