trailing digits

Started by HansS, December 25, 2018, 04:19:01 PM

Previous topic - Next topic

HansS

Altough I understand you could be very busy around the new version of IMatch, I hope someone will have an answer for my question.

In LR I use  filenames like:

  • 20050126_093607_e4500_0162.jpg
  • 20070513_172313_f31_0122
  • 20170901_171953_g2_ps_1030638
  • 20180801_084427_d850_dxo_ap_0011580
  • 20181011_133926_V700_00273
In general: YYYYMMDD_hhmmss_camera_ap1_ap2_camera number suffix
I very much would like to keep using this scheme. The date together with the trailing digits are the only link to the backup files, that were copied straight from the camera or memory card.

The IMatch renamer is a great improvement on LR. Instead of about two dozen (camera-software combinations) rename presets in LR just one preset covers almost everyting (software insert is not ready) in IMatch, but the trailing digits. I thought a regex expression like ([\d])*\b on {File.Name} should do the trick.
But until now I can't get it to work.

Is there a simple way to get those trailing digits added to the filename built with the renamer?

Have a great holiday!

Hans

Mario

Your post is not clear about what you mean with ap1, ap2 camera number and suffix.

Are these Lr terms od did you make them up? How are these filled? From metadata contained in the image? If so, you can easily create the same schema using variables  which give you full access to all metadata in your files, plus powerful formatting options.

We can help better if you tell us exactly where this data comes from (except for the data, which is clear).
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ubacher

You might want to try something like:
{File.Name|substr:4,99}

Look at variables in help and the various ways to process them.

Mario

Your post looks incomplete?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

HansS

@ubacher: Yes you are right, when renaming files straight from camera/memory card the original file name is length of filename and position of file number (file number suffix in LR) are constants per camera. Things get more complicated when you need to rename files that are already imported in LR.


@Mario: Sorry, you are right. I will try to start at the beginning.
In LR I use filenames that consist of
- date created in YYYYMMDD format
- timestamp in hhmmss format
- abbreviated camera model in 2 to 5 characters
optional, repeatable (default none for LR)
- software used for raw conversion other than LR and/or editing in 2 to 6 characters
- original file-number (file number suffix in LR)

Two examples:
20180925_100140_d850_zsd30_ap_014135
  (date_time_NIKON D850_(raw conversion/edit in LR)_ZereneStacker_AffinityPhoto_from file _DSC014135)
20180912_121950_d800_pl_ap_012958
  (date_time_NIKON D800_raw conversion/edit in PhotoLab_AffinityPhoto_from file _DSC012958)

I make a backup copy to a NAS of all photos as they are imported from camera. The original filenumber is used to retrieve files from this backup. Keeping the original file-number in filenames is important to me. As long as IMatch is used alongside LR keeping the original file-number at the end of the filename would help a lot.

I tried to build a renamer preset to replace the above naming scheme.
- date created and timestamp are fine
- abbreviated camera model is an improvement on LR
  repeated use of the replace function
  {File.MD.Exif::Main\272\Model\0|replace:NIKON ==;replace:FinePix F31fd==f31;replace:DMC-G==g}_
- software is doable, possibly by using keywords, that could easily be constructed in LR.
- until now I have not found a way to get the trailing digits from an existing filename.
  I thought a regex expression like ([\d])*\b on {File.Name} should do the trick, but I can't get it working.

Thanks for your patience.

Hans

Reposted, no idea what went wrong.

Mario

Quote- until now I have not found a way to get the trailing digits from an existing filename.

"Trailing digits" means what? Is this a fixed number? Then you can use the substr variable function to extract it.

The Renamer also has a "Digits of Original File Name" step, which considers only the numerical part. For a file named "_DSC134362.jpg" it returns "134362.jpg".
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

HansS

#6
The expression 'trailing digits' I took from your step 'Delete trailing digits' in IMatch's renamer.
Instead of deleting I need to add them to the end of the filename that is built in the renamer.

If the number of digits would be the same for all used camera's or the start of these digits was at a fixed position I wouldn't have started this topic.
The opening post gave some examples:
    20050126_093607_e4500_0162
    20070513_172313_f31_0122
    20170901_171953_g2_ps_1030638
    20180801_084427_d850_dxo_ap_0011580
    20181011_133926_V700_00273

I must admit I don't quite understand what 'Digits of Original File Name' does.
I would have expected 2004031115251645000085 from filename 20040311_152516_e4500_0085, but the result seems to be the digits of the first integer in the filename e.g. 20040311. This is fine and probably more useful than all digits in a row.
However this step would be great if it could be used on the reversed filename. If I am right the regex expression ([\d])*\b would give the same result in this example.

Some examples could be:
    20050126_093607_e4500_0162 > 20050126_093607_e4500_lr_ap_0162
    20181011_133926_V700_00273 > 20181011_133926_V700_dxo_00273

Still hoping there will be a solution,

Hans

Mario

#7
Well, if none of the built-in functions, nor variables and not even regular expressions can do what you want, it may be impossible in IMatch Renamer.
Encoding such a wealth of data in the file name is rather unusual - that's what metadata was invented for 40 years ago. Your use case may be special, though.

I take it that you mean with "trailing digits" the 0011580 part of the file name 20180801_084427_d850_dxo_ap_0011580, correct?

This is based on your sentence

Quote- until now I have not found a way to get the trailing digits from an existing filename.

The regular expression _([0-9]+)$ matches all digits after the last _

It returns ABC for ABC_0011580. You can use it for replace or remove or whatever you need in the Renamer.

I've found that by googling (first hit) and it seems to work.
If this does not work for you, try googling for regexp all digits after the last to find more answers. I'm no regexp expert, sorry.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

HansS

Thank you once more for your patience Mario.

Yes I know what metadata are and how to use them and it is not a regex expert I was looking for.
The regex expression in my opening post selects the trailing digits all right.
But after three weeks I am still struggling with IMatch's user interface.

What I was looking for were just some examples how to implement regex expressions in the renamer.
I was lucky to find Mario's screenshot in micmacmoe's Regular Expression upper and lower case

Thanks

Hans

Mario

There are many examples in the Regular Expressions help topic, and of course you'll find plenty of examples with Google or by following the link right at the top of the Regular Expressions help topic.

The Renamer help also offers many examples, but maybe not for every border case or for users who use complex naming schemata which actually require the use of regular expressions. I doubt that there are many users who will ever need that, else I would get more feedback and would flesh out the Renamer help correspondingly.

QuoteBut after three weeks I am still struggling with IMatch's user interface.

Which part of the IMatch user interface are you having problems with?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

PaulS

Hello Hans,

If I understand your question correctly, you can add a Text and Variables item using the following construct to get trailing characters from the current file name:

    {File.Name|substrr:0,x}

Just replace "x" with the number of characters you would like to return.  Make sure you use substrr (starts from the end and goes backward) and not substr (starts from beginning and goes forward).

Unfortunately this would not adapt automatically for each of your cameras, but you can make a Renamer preset for each camera that defines the number of characters to preserve.

Paul

Mario

I think the tricky bit to solve is to extract the number from the right, with a variable number of digits.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

HansS

Thank you, Paul.

Yes you are right. That is the way I do this in LR. In LR the 'trailing digits' are built in. But retrieving the camera model in a compact format is not. So I have a couple of dozen rename presets. At the moment I do some testing how much time it would cost to rename some 80000 files to a fixed number of digits.

I still hope the flexibility of IMatch will offer a solution.

Hans

HansS

Hello Mario.
Quote from: Mario on December 27, 2018, 09:10:47 AM
The Renamer help also offers many examples, but maybe not for every border case or for users who use complex naming schemata

I think all the LR deserters hope if not expect the LR renamer to be surpassed by a flexible dam like IMatch.
It does, but sadly not for the 'filename number suffix'
Remarks about border cases etc. are hardly helpful and in my opinion do not fit in positioning IMatch as flexible.

There are a lot of examples of regex expressions, but most, if not all to select (=filter) from collections of files.
The one example of regex in the renamer I found in the forum.
Quote from: Mario on February 07, 2018, 11:18:01 AM

This is easily adapted to trailing digits, but I am still looking how to translate this to adding the result to the end of the filename. An alternative would be to select all but the trailing digits, so back to the regex website.

Struggling with the user interface is just that.
It takes time to get used to shortcut keys and there a still many things to get working, but from the essentials the Renamer is the last function I miss.

Hans



Mario

My "border case" comment was based on the fact that so far no user ever requested a feature like this. I use Lr for years and we've got quite a number of former Lr users this year.

After re-reading all the text in this thread, I understand that:

1. In LR you rename files and make LR append the numerical part of the image file name to the end of the output file name. Separated with a _.

For example: "_DSC1234" becomes "bla_bla_bla_1234" in your naming schema.

2. You add these files then into IMatch (?) and want to rename them again, but keeping the _1234 part?
2.1  So IMatch has to rename the file based on the already renamed file name produced by Lr?  --or--
2.2 do you want IMatch to rename the original file but retain the numeric part at the end, like the special Lr feature you used?

Using the original file name (as it comes from the camera) I think you can produce the format as follows:
(Assuming you find a way to set the software, e.g. from some metadata tag or by using a ProjectCode step which prompts you for input when you rename).



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

HansS

Thank you Mario,

Yes, that is working fine.
I expect to start using IMatch alongside LR, PhotoLab and AffinityPhoto.
I would have liked one preset for all cases, but one preset for import of raw files and a preset per program should work fine.
As preset for import of raw files:

An example that insert the last used editor in the workflow:


Thanks for all reactions in this thread.

Hans