Author Topic: How to use variables to a certain # characters in a filename & Replace with?  (Read 701 times)

Offline dougstroud

  • Newcomer
  • *
  • Posts: 37
    • View Profile
How do I type the syntax to remove a specific set of characters in a filename and in a second procedure perform the first step and then replace it with a different text string and in a second step replace it with a particular word?

1) Existing filename- Doug Stroud Photography Logo Ideas_014_Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697
Remove "Doug Stroud Photography Logo Ideas_014_" leaving "Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697" for the file name

2)Existing filename- Doug Stroud Photography Logo Ideas_014_Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697
Replace "Doug Stroud Photography Logo Ideas_014_" with "Miss" resulting in  "Miss Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697" for the file name

I'd like to understand how to do this, not just get the answer, so if it's okay, I will probably have a follow up or two question.

Thanks,

DS

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24767
    • View Profile
    • Camera Bits, Inc.
Doug,

How do I type the syntax to remove a specific set of characters in a filename and in a second procedure perform the first step and then replace it with a different text string and in a second step replace it with a particular word?

1) Existing filename- Doug Stroud Photography Logo Ideas_014_Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697
Remove "Doug Stroud Photography Logo Ideas_014_" leaving "Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697" for the file name

2)Existing filename- Doug Stroud Photography Logo Ideas_014_Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697
Replace "Doug Stroud Photography Logo Ideas_014_" with "Miss" resulting in  "Miss Sarah Pratt_Senior Session_Doug Stroud Photography_S51_5697" for the file name

I'd like to understand how to do this, not just get the answer, so if it's okay, I will probably have a follow up or two question.

You should be able to do this with a simple Find and Replace.  Find: Doug Stroud Photography Logo Ideas_014_
Replace: Miss

Make sure to set the "Filenames" checkbox.  That should do it.  No variables required.

HTH,

-Kirk

Offline dougstroud

  • Newcomer
  • *
  • Posts: 37
    • View Profile
That approach won't work on this issue is that the numerical value following the underscore changes so I need another way to select everything prior to the _S51_5697 (which is the camera assigned filename with the last four characters advancing for the next filename).

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24767
    • View Profile
    • Camera Bits, Inc.
Doug,

That approach won't work on this issue is that the numerical value following the underscore changes so I need another way to select everything prior to the _S51_5697 (which is the camera assigned filename with the last four characters advancing for the next filename).

Please read: https://docs.camerabits.com/support/solutions/articles/48001077381-variable-substring-extraction

As long as the length of the ending part doesn't change, you should be able to use Variable Substring Extraction in the Rename Photos dialog to perform the operation in bulk.

-Kirk

Offline Mick O (Camera Bits)

  • Camera Bits Staff
  • Hero Member
  • *****
  • Posts: 525
    • View Profile
    • Camera Bits
I will also suggest if you don't care about the _014_ part, you might accomplish something like this with a simple "Rename photos" command using the {frame} variable

If you use this as your rename string: Sarah Pratt_Senior Session_Doug Stroud Photography_S51_{frame}

{frame} should insert the camera-assigned frame number so you don't have to worry about matching/replacing any long strings.

Just a thought.

Mick
Mick O
Camera Bits