INTERACT FORUM

Please login or register.

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

Author Topic: Move, Copy, Rename - Truncate filenames in case they're too long?  (Read 1341 times)

amargolis

  • Junior Woodchuck
  • **
  • Posts: 61

I'm reorganizing the folder structure in my library and getting errors due to filename/path being too long on tracks with really long "names." I'm sending all my files to:

Z:\Music Library\Album [Disc #]\[Track#]. [Name]

Ideally the disc # would only be added on multi disc albums, but it won't really bother me that much to have a "1" at the end of each folder name if that's not possible.

Thanks!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Move, Copy, Rename - Truncate filenames in case they're too long?
« Reply #1 on: March 07, 2013, 06:23:22 pm »

How do you want the name truncated?  Just chop off the last portion at some character limit?

Use this to conditionally include [Disc #]:

Z:\Music Library\[Album]/##/IfElse(!IsEmpty([Disc #],1), / [Disc #])\[Track #]. [Name]
Logged
The opinions I express represent my own folly.

amargolis

  • Junior Woodchuck
  • **
  • Posts: 61
Re: Move, Copy, Rename - Truncate filenames in case they're too long?
« Reply #2 on: March 07, 2013, 06:32:40 pm »

To the rescue again, thanks man!

Yeah, fine to just truncate as you described, unless you know of a better way?

Is there any kind of glossary that could help me learn how you build these expressions? So I don't have to bug you all the time.  ;)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Move, Copy, Rename - Truncate filenames in case they're too long?
« Reply #3 on: March 07, 2013, 06:50:42 pm »

You're welcome.

You might want to create a view that tests the length of the entire path/filename, and perhaps modify those Names that are excessive.  You could use:

length(Z:\Music Library\[Album]/##/IfElse(!IsEmpty([Disc #],1), / [Disc #])\[Track #]. [Name])

as a pane column, and you'll see an ordered list of path lengths.

To fix your path, you might just truncate Name with Mid():

Z:\Music Library\[Album]/##/IfElse(!IsEmpty([Disc #],1), / [Disc #])\[Track #]. mid([Name],0,60)

where you change the 60 to the length you want.  You probably don't want to truncate before the path separator, as you might be chopping off a folder.

See the Expression Language wiki for the functions list and some examples.
Logged
The opinions I express represent my own folly.

amargolis

  • Junior Woodchuck
  • **
  • Posts: 61
Re: Move, Copy, Rename - Truncate filenames in case they're too long?
« Reply #4 on: March 07, 2013, 07:33:49 pm »

Good idea, i'll do that to shorten the super long ones. Thanks.

When I use the rule you gave me, (Z:\Music Library\[Album]/##/IfElse(!IsEmpty([Disc #],1), / [Disc #])\[Track #]. [Name]) to create the file path, it's still adding a "1" to the end of album name folders even on single disc albums. I can live with it, but if there's an easy fix, I'll take it!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Move, Copy, Rename - Truncate filenames in case they're too long?
« Reply #5 on: March 07, 2013, 07:55:30 pm »

It will only add Disc # it if there is a value in Disc #.  For your single-disc albums, clear the [Disc #] field.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up