Author Topic: Injecting characters into filename  (Read 2741 times)

Offline Eric

  • Sr. Member
  • ****
  • Posts: 263
    • View Profile
Injecting characters into filename
« on: February 17, 2009, 08:20:47 AM »
What is the syntax if I want to inject a character string into a filename?  I need to add 4 to 6 numbers (would be a constant) into a spot in the filename.  So how would I tell PM to skip over the first say 6 characters in the filename 'inject' _1234_ then continue the filename?

Offline Kirk Baker

  • Senior Software Engineer
  • Camera Bits Staff
  • Superhero Member
  • *****
  • Posts: 24730
    • View Profile
    • Camera Bits, Inc.
Re: Injecting characters into filename
« Reply #1 on: February 17, 2009, 10:01:42 AM »
What is the syntax if I want to inject a character string into a filename?  I need to add 4 to 6 numbers (would be a constant) into a spot in the filename.  So how would I tell PM to skip over the first say 6 characters in the filename 'inject' _1234_ then continue the filename?


Page 47 of the Photo Mechanic manual describes the feature in detail:

Substring extraction is used to ‘extract’ a range of characters from an image variable
so they can be used as normal variables in other fields throughout Photo Mechanic.
The format is:
{variable:index,count:conversion} or {variable:index:conversion}

In either case, <:conversion> is optional

<index> Sets the point in the string at which the operation starts - zero (0) will include all characters, 1 will ignore the first character etc. This value can be positive
or negative. Negative numbers count back from the end of the string, positive numbers count from the beginning.
<count> to extract <count> characters from <index>. <count> may also be omitted altogether which indicates extracting the substring from <index> position to the end of the string.

<conversion> may be one of the following types or may be omitted altogether:

“lc” perform lower-case conversion of all applicable characters
“UC” perform upper-case conversion of all applicable characters
“PC” perform Proper Name case conversion

Here are some examples:

Let’s say {filenamebase} is DSC_1234

Then:
{filenamebase:0,3} yields: DSC
{filenamebase:-4,4} yields: 1234
{filenamebase:-4} yields: 1234
{filenamebase:2,3} yields: C_1
{filenamebase:0:lc} yields: dsc_1234
{filenamebase:0:PC} yields: Dsc_1234

HTH,

-Kirk