INTERACT FORUM

Please login or register.

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

Author Topic: adding / removing strings  (Read 2644 times)

yannis

  • World Citizen
  • ***
  • Posts: 229
adding / removing strings
« on: January 10, 2013, 11:46:26 pm »

Is there a way to append/prepend a string in some field? Or to remove one?

Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: adding / removing strings
« Reply #1 on: January 11, 2013, 12:58:59 am »

In the tag window, click on an artist to edit it, and type in there: =removeright([artist],6) and press enter to have MC remove the last six characters from the artist data. =removeleft([artist],6) would remove the first six characters.

To add, simply type =string[artist] or =[artist]string

You could do this wholesale on a multiple selection of files if you wanted.

-marko

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9165
Re: adding / removing strings
« Reply #2 on: January 11, 2013, 01:02:41 am »

There is a wiki page dedicated to this stuff which you may find helpful. They are called expressions. String manipulation stuff is here, and the removeleft/right stuff is here

It all makes MC a very powerful data manipulation tool indeed.

marko

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: adding / removing strings
« Reply #3 on: January 11, 2013, 08:15:55 am »

Another tip...

If you have a complex pattern that you regularly use to modify other fields, you can make your life easier by making that pattern into its own calculated field.  So, for example, say you want to regularly do something like this:

=RemoveRight(FixSpacing(FixCase([Name], 0)), 6)

Make that (everything above except the leading equals sign) into its own Calculated Field and give it a name (like [NameFixer] or something).  Then, in the future, when you need to fix the same field in the same way, you can just do:

=[NameFixer]

With the Regex() function, these replacements can be very powerful, but quite complex to write.  Making it once and then using it over and over again is a very good thing.

Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

yannis

  • World Citizen
  • ***
  • Posts: 229
Re: adding / removing strings
« Reply #4 on: January 11, 2013, 11:36:01 am »

Thank you all, it's exactly what I was looking for.

But, to be sincere, I think that for such a common need, there should be an easier way, through the interface, maybe in Library options. Having been a user of BulkRename for quite a while, I expected some similar functionality in MC.
Logged

ted_b

  • World Citizen
  • ***
  • Posts: 117
Re: adding / removing strings
« Reply #5 on: May 06, 2013, 09:48:09 am »

I have a specific request from an expert in the expression language.  I do some expressions, things like fixcase, and things like adding "(DSD)" and "(SHM)" and "(MFSL)" to certain categories of my albums, thereby helping me if I have multiples (i.e compare or identify the MFSL to the regular one).  I've put these qualifiers  (especially DSD which is now a huge section) in parentheses using the / command so as to use the parens as text and not as an expression argument, such as  =[album] /(DSD/)  .

Ok, so here is what I need.  Some of my rips are still yelling at me (i.e album titles are in all caps) and yet I stupidly went ahead and categorized them with the parentheses above.  I do not want the fixcase logic to be used on these qualifiers.  So, can I write an expression that is =fixcase([album])up-to-first parentheses ?

Thanks
Ted
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: adding / removing strings
« Reply #6 on: May 06, 2013, 12:25:36 pm »

You could try FixCase(ListItem([Album],0,/()).

EDIT: The reply might be too brief.

Try to put this in an expression column to see the result without changing any tags: FixCase(ListItem([Album],0,/())ListItem([Album],1,/()

If it looks good you can change the tags by entering the expression in the [Album] tag prefixed with =: =FixCase(ListItem([Album],0,/())ListItem([Album],1,/()

I have not tried out the expression, so I do not really know how well it will work with the space you probably have before the "(", and the expression will not work correctly in the tag if the album name contains more than one "(".
Logged

ted_b

  • World Citizen
  • ***
  • Posts: 117
Re: adding / removing strings
« Reply #7 on: May 06, 2013, 01:10:03 pm »

Thanks

The results: 
A WONDERFUL WORLD (DSD)
becomes
A Wonderful WorldDSD)

Almost there.  Also, I have lots of dual paren albums (MFSL) (DSD) so I think maybe I won;t worry about it....
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: adding / removing strings
« Reply #8 on: May 06, 2013, 01:15:56 pm »

I think you will need MrC's Regex skills here. My limited Regex knowledge is a bit rusty.
Logged

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: adding / removing strings
« Reply #9 on: May 07, 2013, 03:30:47 am »

OK, MrC seems temporarily unavailable so I will have a go.

Try this in an expression column:
Regex([Album],/#^(.+?)(\(.*)$#/,-1)FixCase([R1])[R2]

Sort by that column so that files with a value in that column are visible. If you like what you see, use the expression prefixed with = in the [Album] field for _only_ those files with a value in that column. Ctrl+c should be able to undo the change (but I would try it out on just a few files first).

MrC would have a more elegant solution I am sure, and he would actually understand what he is doing (which I do not really so proceed with caution).
Logged

ted_b

  • World Citizen
  • ***
  • Posts: 117
Re: adding / removing strings
« Reply #10 on: May 07, 2013, 08:07:03 am »

Works great!!  Thanks!   :)
Logged
Pages: [1]   Go Up