INTERACT FORUM

Please login or register.

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

Author Topic: Processing Tags  (Read 4752 times)

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Processing Tags
« on: November 08, 2012, 09:11:34 am »

Two things.  
1) I want to remove 3 characters from the front of the names field and make that the new name field (I have a set of names with 01 , 02 in front of them)
2) I want to process an authors field to change for example Peter Rowan to Rowan, Peter for all authors so the length is variable etc.

Any ideas

Peter Rowan
Logged

221bBS

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 703
Re: Processing Tags
« Reply #1 on: November 08, 2012, 09:18:31 am »

1) In the tag window, type "=RemoveLeft([Name],3)" without the quotes in the name field.

2) Select the files and use the Find and Replace tool.


Test out a file or two first before you do a lot.
Logged

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Re: Processing Tags
« Reply #2 on: November 09, 2012, 11:10:45 am »

Makes sense but 1 doesn't seem to work just replaces the name with that expression with or without the quotataion marks.   Find and Replace worked for this changing 01 to null but I would like to know how to make expressions work.  I got this to work - for some reason you can't copy and paste a formula in but if you manually type it it works.

For 2 how can you use find and replace to change (I have a set of names that have useful info after a comma and want the text after the comma to head the name string e.g  rowan, peter  to peter rowan You don't seem to have a POS or a FIND function that returns the position in the string of a character (the comma) so I don't think you can do it.

Peter Rowan
Logged

221bBS

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 703
Re: Processing Tags
« Reply #3 on: November 09, 2012, 06:26:57 pm »

Makes sense but 1 doesn't seem to work just replaces the name with that expression with or without the quotataion marks.   Find and Replace worked for this changing 01 to null but I would like to know how to make expressions work.  I got this to work - for some reason you can't copy and paste a formula in but if you manually type it it works.

For 2 how can you use find and replace to change (I have a set of names that have useful info after a comma and want the text after the comma to head the name string e.g  rowan, peter  to peter rowan You don't seem to have a POS or a FIND function that returns the position in the string of a character (the comma) so I don't think you can do it.

Peter Rowan

1) Copy/paste should work. I do it all the time.

2) Select the files you want to work with. Right-click the files > Library Tools > Find and Replace. Click the "Check None" Button on the bottom left. Check "Author" on the left side. In the "Find what:" field enter "Peter Parker". In the "Replace" field enter "Parker, Peter". Press "OK" Button.

If the field contains "Peter Parker (aka Spider-Man)" it will be changed to "Parker, Peter (aka Spider-Man)". This won't alter anything except what you enter in the "Find what:" field. Hope that clears it up.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Word1, Word2 ==> Word2 Word1
« Reply #4 on: November 09, 2012, 08:09:03 pm »

For 2 how can you use find and replace to change (I have a set of names that have useful info after a comma and want the text after the comma to head the name string e.g  rowan, peter  to peter rowan You don't seem to have a POS or a FIND function that returns the position in the string of a character (the comma) so I don't think you can do it.

To do this Word1<comma>Word2 flip generally, use:

  =if(regex([Name], /#^([^,]+?),\s*(.*)$#/),[R2] [R1],[name])
Logged
The opinions I express represent my own folly.

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Re: Processing Tags
« Reply #5 on: November 10, 2012, 06:30:22 am »

The regex is great.  If I wanted generally to do it the other way round e.g  first name space second name to second name, first name.  How would I change that regex.  It is finding space that confuses me.  I can see that [^,] is where the comma is found.

Regards
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Word1 Word2 ==> Word2, Word1
« Reply #6 on: November 10, 2012, 11:53:17 am »

If you're OK that only the first space will be used (i.e. Little Joe Brown --> Joe Brown, Little)


  =if(regex([Name], /#^(\S+)\s+(.*)$#/), [R2]/, [R1], [Name])
Logged
The opinions I express represent my own folly.

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Re: Processing Tags
« Reply #7 on: November 10, 2012, 05:01:57 pm »

Thanks.  Thats just what I need.

Peter Rowan
Logged

peterdrowan

  • Junior Woodchuck
  • **
  • Posts: 62
Re: Processing Tags
« Reply #8 on: November 11, 2012, 04:15:54 am »

So I don't have to bother you in the future. I am trying to work out how the regex works. I can see that
^(\S+)\s+(.*)$ does the splitting and ^ and $ are the beginning and end of string.  Could you just give a short explanation of how the regex does what it does and then I can build my own.
 =if(regex([Name], /#^(\S+)\s+(.*)$#/), [R2]/, [R1], [Name])

Peter Rowan
Logged

221bBS

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 703
Re: Processing Tags
« Reply #9 on: November 11, 2012, 08:30:19 am »

Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Processing Tags
« Reply #10 on: November 11, 2012, 12:28:35 pm »

Start here with the Regex() wiki page.  It gives a brief overview, points you to the definitive syntax and support guide for the version of regular expression used by MC, and some examples.

This RE in particular:

     ^(\S+)\s+(.*)$

matches against [Name], and does this following:

  ^       match anchored at the beginning of line
  (\S+)  match 1 or more non-whitespace characters and remembers those matched in capture group 1
  \s+     matches one or more whitespace characters
  (.*)    matches 0 or more of any character and remembers those matched in capture group 2
  $       match anchored at the end of the line

In MC, the capture groups are recalled as [R1], [R2], ... [R9].
Logged
The opinions I express represent my own folly.

Flavio61

  • Recent member
  • *
  • Posts: 24
Re: Processing Tags
« Reply #11 on: November 15, 2012, 05:34:02 pm »

Hi,
I use the expression to sort Composer but I have a problem.

In the Composer field I have Claude Debussy [1862-1918], I have created a new field called ComposerSort and I put this expression =if(regex([Composer], /#^(\S+)\s+(\S+)#/), [R2]/, [R1], [Composer]) in Calculated Data Expression. The result is: Debussy, Claude and all works fine, but if in the composer field I have Ludvig van Beethoven [1770-1827] the result is van, Ludvig. How do I change the expression to have Beethoven, Ludvig van?

Very thank's for any help.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Processing Tags
« Reply #12 on: November 15, 2012, 08:14:52 pm »

Will your composers always have a bracketed date?  If so, the bracket can be used as the delimiter instead:

   =if(regex([Composer], /#^(.+)\s+([^[\s]+)\s\[#/), [R2]/, [R1], [Composer])
Logged
The opinions I express represent my own folly.

Mike48

  • World Citizen
  • ***
  • Posts: 214
Re: Processing Tags
« Reply #13 on: November 16, 2012, 12:21:41 am »

Try this

http://www.ultrapico.com/Expresso.htm

Thanks for this!  The old language APL used to be described as "Martian," perl as "line noise," and I'd say regex language is deeply in the spirit of perl.

Expresso is a great way of getting a handle on it.
Logged

Flavio61

  • Recent member
  • *
  • Posts: 24
Re: Processing Tags
« Reply #14 on: November 16, 2012, 09:08:04 am »

Will your composers always have a bracketed date?  If so, the bracket can be used as the delimiter instead:

   =if(regex([Composer], /#^(.+)\s+([^[\s]+)\s\[#/), [R2]/, [R1], [Composer])

Very thank's, works fine.
Logged

timwtheov

  • Galactic Citizen
  • ****
  • Posts: 354
Re: Processing Tags
« Reply #15 on: May 25, 2013, 07:43:54 pm »

I know this is an old topic, but I was hoping MrC (or someone) could help me out.  I'm using the expression noted above (changing first last to last, first) in both my Audio [Composer] and in Video [Director] fields.  I'm running into the same problem as Flavio61, but in my case, I don't have brackets as delimiters:  just a name like "Ludwig van Beethoven" or "Paul Thomas Anderson" for video, and if I use the expression as is, I get "Thomas Anderson, Paul," or "van Beethoven, Ludwig," when obviously I want "Anderson, Paul Thomas" or "Beethoven, Ludwig van."  Expression language is brand new to me, and frankly, it makes my head hurt to try and parse it all out.  How might that expression be changed so that what I have above would happen, or given that someone could conceivably have more than 3 names (such as Johannes Chrysostomus Wolfgangus Theophilus Mozart, if one were being really extensive, if not pretentious), is there an expression that could take in any possible number of names, with always the last name, well, last? Naturally, I could do all this manually, but as I'm getting into expression language, I like the idea of automating. 

Thanks for any help!
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Processing Tags
« Reply #16 on: June 19, 2013, 07:14:32 pm »

Sorry for the late reply.

There's no way to automatically do this since the number of names in a first or last name is arbitrary.  Only humans can semi-reliably process ambiguous language.

Specific expressions can be used to do the swapping (e.g. all last names with 3 words).
Logged
The opinions I express represent my own folly.
Pages: [1]   Go Up