Buddy file and version help

Started by P.Jones, July 25, 2014, 05:03:17 PM

Previous topic - Next topic

P.Jones

I use _m to identify my master jpg files i.e.

P1012400_m.JPG

IMG_9460_m.JPG

I'm trying to do a Version and Buddy File rule so that if it finds version files like

P1012400.JPG

IMG_9460.JPG

these will become the versions.

I thought the Master expression would be

*_m\.(jpg)$

but that don't work

My Link Expression =  ^(_*{name})[+\-_]*[0-9|a-z]*\.(jpg)$


Erik

#1
I think you'll need to look at the help file closely. 

A very basic and limited method to get what you want to work would look something like this:

Master Expression:  .+_m\.jpg$

Replacement: _m//

Link:  {name}\.jpg


With what you showed there are two key things:

1. You need to look closely at how regular expressions work.  There are many ways to achieve what you need, and what I did above is quick and dirty and not necessarily best.
2. The Master Expression.  The * isn't matching anything.  At the simplest, you need to put a  .  in front of your Master expression (which is the wildcard) and the * or + allows for a multitude of characters to match. 

edit: actually at the simplest, you could remove your * and just look for all files that end in _m.jpg

3. Your version files appear to be subtracting characters from the Master.  This means you need to use the replacement expression to strip the file down to a "root" file name.  Look at the example in the help for the default replacement expression.  It's there to strip a _ from the front of a file name.  In the version I put above, I'm stripping the _m from the master and replacing it with nothing.
4. The final link expression is just the remaining name and file extension.  You'll have to modify that for any changes you might have with versions or buddy files.  You might think about what you'd do if you had multiple versions of a file.

The last thing I suggest is looking at what I did and changing it to be more robust and "safe".  Using the . and + and * is considered a bit careless in regular expressions and could end up with issues depending on how your file names work out.




P.Jones

Quote from: P.Jones on July 25, 2014, 05:03:17 PM
I use _m to identify my master jpg files i.e.

P1012400_m.JPG

IMG_9460_m.JPG

I'm trying to do a Version and Buddy File rule so that if it finds version files like

P1012400.JPG

IMG_9460.JPG

these will become the versions.

I thought the Master expression would be

*_m\.(jpg)$

but that don't work

My Link Expression =  ^(_*{name})[+\-_]*[0-9|a-z]*\.(jpg)$


Think I cracked it

Master Expression  = _m\.(jpg$

Replacement Expression = ^_*//_m//

Link Expression =  ^(_*{name})[+\-_]*[0-9|a-z]*\.(jpg)$

P.Jones

Hi Erik

I see you posted just after I had solved it.

I'd forgot to remove the _m as you stated