INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Truncating filename / path using expression  (Read 4626 times)

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Truncating filename / path using expression
« 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
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Truncating filename / path using expression
« Reply #1 on: September 06, 2015, 09:40:54 am »

Try:

=left(removeright([filename],5),240).[file type]

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Re: Truncating filename / path using expression
« Reply #2 on: September 06, 2015, 09:45:58 am »

Marko, seems to work brilliantly, thanks a lot
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Truncating filename / path using expression
« Reply #3 on: September 06, 2015, 09:50:06 am »

You're welcome.

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Re: Truncating filename / path using expression
« Reply #4 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?
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9140
Re: Truncating filename / path using expression
« Reply #5 on: September 06, 2015, 10:30:28 am »

Yes, like so...

=left(filepath()filename(,0),240).[file type]

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Re: Truncating filename / path using expression
« Reply #6 on: September 06, 2015, 10:52:26 am »

Even more brilliant, thank you
Logged

jacobacci

  • Galactic Citizen
  • ****
  • Posts: 256
Re: Truncating filename / path using expression
« Reply #7 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
Logged

RD James

  • Citizen of the Universe
  • *****
  • Posts: 1871
Re: Truncating filename / path using expression
« Reply #8 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".
Logged
Pages: [1]   Go Up