INTERACT FORUM

More => Old Versions => JRiver Media Center 21 for Windows => Topic started by: jacobacci on September 06, 2015, 09:31:18 am

Title: Truncating filename / path using expression
Post by: jacobacci on September 06, 2015, 09:31:18 am
The context of the question is that I am converting FLAC files to m4a.
I have several files that have target path names (incl. the filename) with >259 chars and they are causing problems in FLAC -> m4a conversion.
I am trying to shorten the paths to around 240 chars using the expression language. I have read up on the left, filename etc. functions in the Wiki, but could not find an expression that works. I need to extract the name of the full path (without the file extension), trim that from the right and then put the file extension back on.
I tried
=left(([filename],0),240).flac
and different permutations of this but that didn't quite do the job.
Could anyone suggest an expression? Thanks a lot
Title: Re: Truncating filename / path using expression
Post by: marko on September 06, 2015, 09:40:54 am
Try:

=left(removeright([filename],5),240).[file type]
Title: Re: Truncating filename / path using expression
Post by: jacobacci on September 06, 2015, 09:45:58 am
Marko, seems to work brilliantly, thanks a lot
Title: Re: Truncating filename / path using expression
Post by: marko on September 06, 2015, 09:50:06 am
You're welcome.
Title: Re: Truncating filename / path using expression
Post by: jacobacci on September 06, 2015, 10:12:34 am
Just one more question, Marko
In the WIKI I found the following:

filename(filepath, include suffix)
The FileName() function returns the file name part of filepath. Inclusion of the file's suffix depends on the include suffix argument.
0   Suppress file suffix
1   Include file suffix
Argument filepath is optional (defaults to [filename]).
Argument include suffix is optional (defaults to 1).

Could the 0 argument be used instead of truncating 5 letters from the right, if there were a mix of different file types, not all 4 letters?
Title: Re: Truncating filename / path using expression
Post by: marko on September 06, 2015, 10:30:28 am
Yes, like so...

=left(filepath()filename(,0),240).[file type]
Title: Re: Truncating filename / path using expression
Post by: jacobacci on September 06, 2015, 10:52:26 am
Even more brilliant, thank you
Title: Re: Truncating filename / path using expression
Post by: jacobacci on May 20, 2018, 01:20:10 am
Hi all
I have tried to use the above expression to shorten file paths the other day. For the life of me I could not figure out how I had done that the last time around. Which field do I paste the expression to?
I cannot select the "Filename" field in the tagging pane if more than one track is selected?
Thanks a lot
Title: Re: Truncating filename / path using expression
Post by: RD James on May 20, 2018, 04:27:00 am
Hi all
I have tried to use the above expression to shorten file paths the other day. For the life of me I could not figure out how I had done that the last time around. Which field do I paste the expression to?
I cannot select the "Filename" field in the tagging pane if more than one track is selected?
Thanks a lot
Use the "rename, move, and copy tool".