Author Topic: Renaming: Can you remove or replace parts of the name?  (Read 9326 times)

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Renaming: Can you remove or replace parts of the name?
« on: September 26, 2007, 03:10:07 PM »
I was reading the Photo Mechanic manual, which describes how to add Variables to a file name.  This is very convenient.  However, I didn't see anything on removing parts of a name in the renaming process.  Is this possible?  For example, when I am browsing my Master files named like this: "TSmith_070926_2126_Master.TIF", I would like to create a lower resolution JPG from the Master and rename it: "TSmith_070926_2126_Proof.JPG" or add some such suffix which is appropriate.  I don't just want to add "_Proof" right after "Master" in the name because it would not be correct.  I really want to replace "Master" with "Proof".  If this is possible, I'd love to learn how to do it. I can use an independent renaming software, but it would be very convenient to be able to do this within Photo Mechanic.  Thanks.
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24767
    • View Profile
    • Camera Bits, Inc.
Re: Renaming: Can you remove or replace parts of the name?
« Reply #1 on: September 26, 2007, 03:30:52 PM »
Todd,

I was reading the Photo Mechanic manual, which describes how to add Variables to a file name.  This is very convenient.  However, I didn't see anything on removing parts of a name in the renaming process.  Is this possible?  For example, when I am browsing my Master files named like this: "TSmith_070926_2126_Master.TIF", I would like to create a lower resolution JPG from the Master and rename it: "TSmith_070926_2126_Proof.JPG" or add some such suffix which is appropriate.  I don't just want to add "_Proof" right after "Master" in the name because it would not be correct.  I really want to replace "Master" with "Proof".  If this is possible, I'd love to learn how to do it.

You can use variables substring extraction like so:

{filenamebase:0,-6}Proof

and in your example, TSmith_070926_2126_Master.TIF will become TSmith_070926_2126_Proof.JPG when you save as JPEG.  What my example does is extract from the first character (starting from zero) continuing up to the end-6 characters, so basically all but the last six characters are returned, and then Proof is appended.

HTH,

-Kirk

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #2 on: September 26, 2007, 03:35:52 PM »
Excellent!! That's exactly what I needed to know.  Thank you so much! Todd
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #3 on: September 26, 2007, 04:03:27 PM »
The trick you just gave me worked great.  I only ran into trouble when I had two versions of an image (where the second image was named:  "TSmith_070926_2126_Master2.TIF".  The extra number threw off the -6 extraction causing the proof image to be named "TSmith_070926_2126_MProof.JPG". I'm catching on, though, and solved my own problem by trying this Variable: {fbase:0,19}Proof.  This worked great on both versions of the TIF file.  What this example does is extract from the first character (starting from zero) continuing up to the 19th character.  Since I'm not counting backwards from the end of the file, extra digits make no difference.
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #4 on: October 02, 2007, 12:36:41 PM »
Ok, let's take this a step further.  Looking at the same example, where the orginal filename is "TSmith_070926_2126_Master2.TIF", how do I splice out the "Master" without removing the "2"?
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24767
    • View Profile
    • Camera Bits, Inc.
Re: Renaming: Can you remove or replace parts of the name?
« Reply #5 on: October 02, 2007, 03:43:50 PM »
Ok, let's take this a step further.  Looking at the same example, where the orginal filename is "TSmith_070926_2126_Master2.TIF", how do I splice out the "Master" without removing the "2"?

{filenamebase:0,19}{filenamebase:-1,1}

will result in:

TSmith_070926_2126_2.TIF

...though I haven't tried it myself.

HTH,

-Kirk

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #6 on: October 02, 2007, 04:10:23 PM »
Yep.  That works great!

Now this may be out of my league, but is there a way to put conditions on these macros?  For example, is it possible to do something like this?:

If total length of the string is 25, then perform this macro:  {fbas:1,18}
If total lenght of the string is 26, then perform this macro:  {fbas:1,19}{fbas:-1,1}

This would take care of both kind of names that my RAW processer creates:  "TSmith_070926_2126_Master.TIF" and "TSmith_070926_2126_Master2.TIF", and would reaname them "TSmith_070926_2126.JPG" and "TSmith_070926_2126_2.JPG" respectively.

Any thoughts would be greatly appreciated.

Thanks,
Todd
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #7 on: October 02, 2007, 04:36:22 PM »
I just tried {fbas:0:18}{fbas:25,1} which worked like this in both cases:

"TSmith_070926_2126_Master.TIF" became "TSmith_070926_2126.JPG"  and
"TSmith_070926_2126_Master2.TIF" became "TSmith_070926_21262.JPG".

Not a bad solution, but...

I couldn't find a way with this logic to add a "_" between the last two digits of the second example.

Todd
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24767
    • View Profile
    • Camera Bits, Inc.
Re: Renaming: Can you remove or replace parts of the name?
« Reply #8 on: October 02, 2007, 04:53:00 PM »
Todd,

I just tried {fbas:0:18}{fbas:25,1} which worked like this in both cases:

"TSmith_070926_2126_Master.TIF" became "TSmith_070926_2126.JPG"  and
"TSmith_070926_2126_Master2.TIF" became "TSmith_070926_21262.JPG".

Not a bad solution, but...

I couldn't find a way with this logic to add a "_" between the last two digits of the second example.

Well you could do this:

{fbas:0:18}_{fbas:25,1}

But it will always be adding the underscore.

-Kirk

Offline Todd Smith

  • Newcomer
  • *
  • Posts: 21
  • I love Photo Mechanic!
    • View Profile
    • Fine Art Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #9 on: October 02, 2007, 05:21:37 PM »
Yeah, I tried that.  I was just hoping to avoid having the extra underscore at the end of the filename base when there is not version number.
Todd Smith Photography
P.O. Box 1802
Oroville, WA 98844
509-340-3505
http://www.toddsmithphotography.com

Offline ehannigan

  • Newcomer
  • *
  • Posts: 19
    • View Profile
Re: Renaming: Can you remove or replace parts of the name?
« Reply #10 on: May 30, 2008, 09:39:21 AM »
I know this bumping an old thread....

How do I take a file named "20080524TrishaJosh106_4x6" and rename it "2008524TrishaJosh_473237" if

(a) I want to save that naming string (since 4x6's I send to exposure manager must all have the "underscore 473237" attached (and different ones for other sizes

and

(b) if the filename can exceed three digits - ie. not 106 as above but 1106.

I tried the above example and only got a file renamed "filebase...." Am I not picking up the filenamebase correctly? Is that set in IPTC?

Thank you very much..

Edward

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24767
    • View Profile
    • Camera Bits, Inc.
Re: Renaming: Can you remove or replace parts of the name?
« Reply #11 on: May 30, 2008, 09:44:24 AM »
Edward,

I know this bumping an old thread....

How do I take a file named "20080524TrishaJosh106_4x6" and rename it "2008524TrishaJosh_473237" if

(a) I want to save that naming string (since 4x6's I send to exposure manager must all have the "underscore 473237" attached (and different ones for other sizes

and

(b) if the filename can exceed three digits - ie. not 106 as above but 1106.

I tried the above example and only got a file renamed "filebase...." Am I not picking up the filenamebase correctly? Is that set in IPTC?

Perhaps you're leaving off the { and } around your variables?

I'm not sure exactly what you're going for but this may work for you:

{fbas:0,18}_473237

You should be able to look at the previewed filenames to see if it is working for you.

HTH,

-Kirk


Offline ehannigan

  • Newcomer
  • *
  • Posts: 19
    • View Profile
Re: Renaming: Can you remove or replace parts of the name?
« Reply #12 on: May 30, 2008, 10:09:14 AM »
 :'(

That gives me a file named "{fbas-0,18}_473237"


Offline Hayo Baan

  • Uber Member
  • ******
  • Posts: 2552
  • Professional Photographer & Software Developer
    • View Profile
    • Hayo Baan - Photography
Re: Renaming: Can you remove or replace parts of the name?
« Reply #13 on: June 02, 2008, 08:28:34 AM »
Edward,

Some of PM's file renaming input boxes won't allow you to type in an illegal filename character (a : is illegal under windows).  There is, however, a trick to get this working:

if you let PM know you are typing a variable name (by type the closing curly brace), you can then type the : inside the {}'s

So if you type {fbas}_47327 first, then change this to {fbas:0,18}_473237, you should be fine!

Hope this helps
Hayo Baan - Photography
Web: www.hayobaan.nl