INTERACT FORUM

Please login or register.

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

Author Topic: Expression help please  (Read 1402 times)

sirshambling1

  • Recent member
  • *
  • Posts: 6
Expression help please
« on: October 04, 2013, 06:37:18 am »

I am the proud owner of a new Ibasso DX50 dap but having problems getting the thing to play some of my music files. I am advised that the reason some MP3s don't play is that the filename must be 30 characters long or less.

So I need to rename my files to limit their length. I've tried to write an expression to go into the "Rename Move and Copy Files" dialogue box using the "length" function but am only getting the actual number of characters in the filename rather than limiting it's length.

If anybody could help me with the correct expression which will result in the filename length limitation I need I'd be very grateful. Thank you.

(I know this post shows as my first one, but as "sirshambling" I've been a member of this forum for many years. I couldn't recreate my login details on my new PC sadly.)
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression help please
« Reply #1 on: October 04, 2013, 11:35:24 am »

Try using instead Mid().  Example:

   mid([name], 0, 28)
Logged
The opinions I express represent my own folly.

sirshambling1

  • Recent member
  • *
  • Posts: 6
Re: Expression help please
« Reply #2 on: October 04, 2013, 12:58:06 pm »

Hi Mr C, Thank you very much for trying to help me but your suggestion doesn't seem to help.

The file I’m using as a test has the current filename:-
P:\Al Green\Don’t Look Back\Your Love (Is More Than I Ever Hoped For).mp3
I’m trying the “Rename, Moves & Copy Files” process.
If I use the Directory setting “P:\” and try the Expression Editor after clicking “Filename” and fill the Editor likethis 
Mid([Name] 0, 28) it gives the result “P:\e” as a the Filename.
If I change this to
[Name]Mid([Name] 0, 28) I get the result
“P:\Al Green\Don’t Look Back\Your Love (Is More Than I Ever Hoped For)e.mp3"

I think the logic I'm looking for is to count the number of characters in the Filename, and if it is longer than "30" then delete the extra characters from the Right side of the Filename, leaving the Directory info untouched.

But would that delete the 3 letter suffix "MP3" or the "." in front of it??

And even if I've got the logic correct I really don't know how to write an Expression that would deliver a correct result!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression help please
« Reply #3 on: October 04, 2013, 02:00:50 pm »

I hesitated to provide that hint, as I knew it wouldn't be enough, but also didn't know your path names, nor file names (nor filename template).

You can use filename(,0) to yield the file's name without the extension.  The Rename tool will add it back.  So:

   mid(filename(,0),0,30)

is approximately what you want for the Filename portion (maybe you'll want < 30 chars though).
Logged
The opinions I express represent my own folly.

sirshambling1

  • Recent member
  • *
  • Posts: 6
Re: Expression help please
« Reply #4 on: October 04, 2013, 02:39:25 pm »

Hello MrC, It is very kind indeed of you to help me again. The syntax you provided for me seems to work beautifully. For filenames longer than 30 characters it reduces the number to 30, and for filenames shorter than 30 characters it has no effect.

Just what I wanted. I'm really grateful.

Finally just so I can understand a little further against the file:-

P:\Al Green\Don’t Look Back\Your Love (Is More Than I Ever Hoped For).mp3

The (,0) portion of the script takes out the .MP3 suffix?
The next part ",0," takes out the second section of the filename ie "Don't Look Back"?
The final part "30" is the length in characters of the parts that remain ie "Al Green/Your Love (Is More Than I Ever Hoped For)"?
The end result inserts "-" between "Al Green" and "Your Love Is More" - where does that come from?

Once again I'm am really grateful to you for all your help. John.

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression help please
« Reply #5 on: October 04, 2013, 02:46:52 pm »

The filename function is described here (as are other functions):

    http://wiki.jriver.com/index.php/Expression_Language#FileName

The function takes two arguments, and we omitted the first one to use the default value (which is [Filename]), and specified the second one as 0.  Hence filename(,0).  The 0 is the include suffix argument, so we've indicated we don't want the suffixed included in the filename.  The filename() function returns only the file's name segment (e.g. the same contents in the [Filename (name)] field), not the full path (which is the [Filename] field).

The output from the filename() function is then supplied as an argument to the Mid() function, where 0 is the start position, and 30 is the quantity of characters to return.
Logged
The opinions I express represent my own folly.

sirshambling1

  • Recent member
  • *
  • Posts: 6
Re: Expression help please
« Reply #6 on: October 04, 2013, 03:28:08 pm »

Thanks again MrC - I have been studying the Wiki page on Expressions without a great deal of success I must admit. It was where I originally found the "length" term.

I think I understand your explanation but will need to think about it further. Trying to learn from your help is the least I can do.

Thanks very much once again.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Expression help please
« Reply #7 on: October 04, 2013, 03:32:30 pm »

Your perceived lack of success is my failure too.  Please feel free to share feedback.

Start from the top of the page, and work your way down.  Read it lightly.  Then examine a few examples until it looks less foreign.  Then try re-reading the front matter again.  It should start to make more sense.
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up