INTERACT FORUM

Please login or register.

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

Author Topic: Find position of character in a string  (Read 1478 times)

dsmnz1

  • Member
  • *
  • Posts: 3
Find position of character in a string
« on: May 05, 2017, 10:24:21 pm »

Any help appreciated.

I would like to find the numeric position of a character in a string using the JRiver expression language.

Example:

String = 'U2 - Boy'

The value I want to return is 'U2'

However the string could also be 'Ultravox - blah blah'

So if I know the position of the '-' then I can grab the artist.

Or is there another way to do it?

Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8947
Re: Find position of character in a string
« Reply #1 on: May 05, 2017, 11:02:56 pm »

It depends where your string is. For example, if your string were the filename, you could use the "fill properties from filename" tool, passing it a template like so:
[Artist] - []

This will extract the artist, and discard everything after the first "-".

There are other ways to use the hyphen as a delimiter, but need more info about the source string, and destination field before being able to offer any really constructive advice.

dsmnz1

  • Member
  • *
  • Posts: 3
Re: Find position of character in a string
« Reply #2 on: May 06, 2017, 12:24:22 am »

Thanks for the help

I'm trying to copy jpg files from one location to another and want to strip bits of the filename so I can create the right string

For example

C:\Users\David\AppData\Roaming\J River\Media Center 21\Cover Art\Albums\U2 - Boy.jpg

becomes

M:\Music\CDs - Backup\U2\Boy\folder.jpg
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 8947
Re: Find position of character in a string
« Reply #3 on: May 06, 2017, 01:45:31 am »

OK. So, getting over my initial 'what??' reaction, which spun really rapidly through things like...

To do that, with MC, you're going to need the files imported to the library...
why would you want the cover art imported to the library...
why would you want back ups of your cover art in the library... (not necessarily)

to 'ach well, they can always be removed or otherwise managed afterwards' and 'I'm sure there's a perfectly good reason' :D
Let's get to it...

First of all, you'll need all the cover art files in that folder imported because you cannot easily browse the hidden appdata folder from within MC.
Once done, get yourself a file list that lists only those images. If you need help with this, just ask.
Select them all (this is why the previous step is important)
right click > Library tools > 'fill properties from filename'
Select 'Template'
Uncheck 'directories'
Check 'File name'
Under 'File name', enter [artist] - [album] (see attachment "fpffn.jpg")
Press "Ok" and MC will fill the Artist and Album fields for these files accordingly. Remember, if there are any illegal file system characters there, such as question marks etc., these will all be represented by an underscore. In this case though, the data will be used for creating folders, so probably not an issue.

Next, make the copies. Do this using the rename, move and copy' tool...
With all files selected, right click > Library tools > 'Rename, move and copy files'
Fill it out as shown in the attachment "rmcf.jpg". Pay attention to the top field. It defaults to "Move". Use the drop menu to change that to "Copy" (NOT 'copy and update', unless that's what you want.)
Press "Ok" and all your files will be copied as you requested.

That should be that job done.
Maybe try a couple before going wholesale to be sure you have it right.
Do you want the original cover art files to remain in the library? If not, select them, press 'Delete', choose the "remove from media library " option and press OK.

Seems a lot, but you'll probably do this quicker than it took me to create this post.
Good luck.

-marko

dsmnz1

  • Member
  • *
  • Posts: 3
Re: Find position of character in a string
« Reply #4 on: May 06, 2017, 01:59:08 am »

Mark,

LOL I'm pretty certain I don't have a perfectly good reason, other than I thought I could do this easily in JRiver rather than script something in PowerShell.

Excellent instructions.

Thanks
Logged
Pages: [1]   Go Up