Renaming -- Insert Character

Started by WebEngel, July 30, 2014, 04:04:04 PM

Previous topic - Next topic

WebEngel

Hi,

in one of my renaming schemas, I need to insert a character at a certain position as follows:

Original filename:
20140727122440.m2ts
should be renamed to:
20140727-122440.m2ts

So I need to insert a dash at position 9.

I don't think this can be done with the existing Imatch Renaming options as all substring functions work only once while I need two substrings.  One would need Regex.  Am I right?

If yes, any expert who can help out with Regex?

Thanks,
Martin

Mario

Why don't you just use three test steps?

1. First part of the file name (file name variable, substring)
2. -
3. Second part of file name (file name variable, substring)

Easy.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lenmerkel

It looks like your filename is a date-time stamp (maybe based on capture time?). If so, and assuming your file has EXIF info, you could just as easily rebuild your filename as:

1. image_date_variable
2. '-'
3. image_time_variable
Over the hill, and enjoying the glide.

WebEngel

Quote from: lenmerkel on July 30, 2014, 05:31:39 PM
It looks like your filename is a date-time stamp (maybe based on capture time?)

It is a timestamp, but the file is an m2ts movie container.  The Imatch metadata functions don't do what I want to do.

WebEngel

Quote from: Mario on July 30, 2014, 04:11:27 PM
1. First part of the file name (file name variable, substring)
2. -
3. Second part of file name (file name variable, substring)
Easy.

Seems I don't get it.

BTW, I never understood what the dialog box "Steps" does: whenever I change the value, it does so for all Processing Instruction Boxes below.  So the only way to reorder the Processing Instructions is to use the arrows.

Doing it with substrings was also my idea, but as soon as I have removed the latter part, it is not going to return, or?

So what I have is:
Original File Name
Substring 1,8
Test –

That gives me the first part of my filename---so far so good .

If I add another Substring function, it is processing the result of the previous step which no longer contains the second part of my filename.

I cannot add another "Original File Name" (Imatch restriction to not use it twice).  In my case, I could add "Digits of Original filename" (because it does not contain any letters).   It does not help either as the entire filename is added, but I only need the second half.

I would need to group the functions (what one would do in maths with brackets). Something  (Orignal file name*substring)+Text+(Original Digits*substring).

So I am either completely dumb or it does not work the way

thrinn

Don't think too complicated  ;)
Just use a single Text step with
Quote{File.Name|substr:0,8}-{File.Name|substrr:0,6}

Means: Take the first 8 chars of the filename, then a hyphen, then the last 6 chars. Does this fulfill you needs?
Thorsten
Win 10 / 64, IMatch 2018, IMA

Mario

Use a simple Text step and then

{File.Name|substr:0,8}-{File.Name|substr:9}.{File.Ext}

This produces exactly the file name you need.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

lenmerkel

#7
Quote from: WebEngel on July 30, 2014, 08:03:39 PM
So I am either completely dumb or it does not work the way

We're all dumb, until we learn. Then we're smart.  ;)

Here are the 3 steps you need (filling out what Mario suggested):


  • {File.Name|substr:0,8}
  • -
  • {File.Name|substr:8,6}

The steps in a Renamer setting are executed in the sequence you specify. You are correct in that the result of a step is the starting point for the next step. However, how the previous step's result is used depends on the type of following step. For example, the darker green steps modify the previous result (e.g. 'Remove Text', 'Substring'). The orange step appends to the previous result (e.g. 'Text'). Similarly for the 'other' green steps (e.g. 'Year in YY format').

What the above solution does is to execute three 'Text' steps to simply append three pieces together. Notice that we're not using the pale blue 'Original File Name' step at all. In the Text steps, we are referring to the {File.Name} variable, with an appropriate substr modifier. You can learn about variables and their various modifiers in the Variables section in the IMatch Help.

The orange 'Text' step is deceptively 'discrete'. Because it has direct access to variables and all of your metadata, it is probably the most powerful renaming step of all.

Oops: Didn't see that Thorsten & Mario had already replied as I was replying. They are both correct of course that the 3 Text steps can be combined into a single Text step.
Over the hill, and enjoying the glide.

WebEngel

#8
Quote from: Mario on July 30, 2014, 08:24:23 PM
Use a simple Text step and then

{File.Name|substr:0,8}-{File.Name|substr:9}.{File.Ext}

This produces exactly the file name you need.

That helped.  Thanks.  Did not know that there was a substring function available that can work on the variables.  So far I had only tried the Processing Instruction "SubString" within the Renamer.

Always surprised how powerful Imatch is.

Thanks also to the other posters.

Mario

When you work with variables, I strongly suggest that you read the help topic on Variables. Just type variables into the help index.
Variables are used in many features in IMatch, and they are immensely powerful and flexible. Browse the help topic to learn what they can do. This may help you with many steps in your workflow.

Tip: Use the handy Var Toy App in the App Panel to try variables out.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook