Renamer: Keeping suffixes of variable length

Started by stahl, April 22, 2019, 07:29:02 PM

Previous topic - Next topic

stahl

Hello,
I work with suffixes like "-e" or "-e2f" to mark derivatives while originals have no suffix. I am struggling how to keep these suffixes when using renamer. The trouble is that the length of the suffix varies, so I can't use substr or substrr on the file name. At the same time, I don't seem to be able to apply a regex (like "-.*") to the file name to extract the suffix.

Example:
oldname.nef      should become  newname.nef
oldname-e.jpg    should become  newname-e.jpg
oldname-e2f.jpg  should become  newname-e2f.jpg


Any idea how I could achieve this?

Thanks, Stef

Mario

Maybe you combine an "Original File Name" step (1) and a "Text Replace" step (2) ?
Replace the part of the original file name you want to rename with a new text. This keeps all your suffices unchanged.

In your case you would use "oldname" as the "Replace:" parameter and "newname" as the "With:" parameter.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

stahl

Hello Mario,
exactly, this is what I would like to do. The trouble is I haven't found a way to let the renamer know where "oldname" ends in the original file name, i. e. at the hyphen (and not after a fixed number of characters).

I have files in my naming convention like these:
yyyymmdd_hhmm_UIID_ShortCaption.nef              should become  newname.nef
yyyymmdd_hhmm_UIID_ShortCaption-e.jpg            should become  newname-e.jpg
yyyymmdd_hhmm_UIID_NotSoVeryShortCaption.nef     should become  newname.nef
yyyymmdd_hhmm_UIID_NotSoVeryShortCaption-e2f.jpg should become  newname-e2f.jpg


but also files almost out of the camera like
_DSC4711.nef    should become  newname.nef
_DSC4711-o.jpg  should become  newname-o.jpg


or even, from other photographers or people sending me files,
lolcat.gif    should become  newname.gif
lolcat-c.gif  should become  newname-c.gif

(okay, not literally)

Is there a way to do this or will this be a feature request?
Stef


Mario

Not all problems can be solved with generic tool like the Renamer - although it offers a lot of flexibility.
You are using very complicated file names of varying lengths with varying formatting and varying postfixes, dates, times, guids and whatnot.
I doubt there will be a way to untangle this and replace some of the text with another text.

You would need a feature that takes one or two regular expressions to determine the start cut / end cut positions and then replaces the cut out with another text.
While this is doable with a very purpose-built feature, I doubt that more than one or maybe a handful users will ever need it. Way too complex and specialized. Never had a similar request.
I would suggest you look into writing a custom app that understands your very special file names and knows how to rename them.

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

stahl

Hello Mario,
thanks. I thought so but was hoping I missed something.

Actually, what I like about this hyphen versioning scheme (derived from the old sinus, GAMB/SAMBA and impulseAdventure workflows) is that it is so simple and flexible: Just stick a hyphen to any filename of any odd origin and naming scheme, and IMatch will know it's a version of the file without the hyphen.

(The old naming convention with date, UIID and short caption indeed is rather too komplicated - which is exactly why I want to rename those files ;-) )

Regards, Stef

sinus

Hm, in my system:

20170201-0853-307341-s-ref-kirche_m.nef
20170201-0853-307341-s-ref-kirche_m_v1.jpg
19600730-1558-007231-s-pri-historisch_a.jpg
19941003-1455-031380-c-pri-keller_m_v1.jpg

all the masters and versions starts with a underscore _
Hence with the first underscore the (important) stuff begins.

I am not sure, but I am quite confidence, if this is the case also in your system, then there it should be a possibilty to say the renamer, "delete all letters before the underscore and hold the rest like it is. Instead the text before write the new text".

But if  you have files from ohter photographers, then this will not work either.

Good luck, maybe a custom app would sove your problem for sure.
Best wishes from Switzerland! :-)
Markus

Mario

#6
I could envision a "Rep0lace Before" or "Replace After" Renamer step, but that would probably not help with all the samples posted here, which mix various lengths with file name sections separated by _ or - or ...
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Mario

I have enhanced the Renamer by adding two new step types:

"Replace Before" and "Replace After"

Assuming a file name like "ABC-DEF.jpg":

1. Replace before "-" with "123" results in "123-DEF.jpg"
2. Replace after "-" with "345" results in "ABC-345.jpg"

This should allow to handle a lot of tricky cases. Including at least most of the ones we discussed in this thread.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Best wishes from Switzerland! :-)
Markus

stahl

Thank you, Mario!
I thought it over: I think what I need is the ability to insert text/variables before the bits of text that previous steps in the renamer have already created (right now I can only insert at the end):

1. Add text or variable: {file.name}
2. Replace before "-" with ""
3. Add text or variable at the beginning: newname ...

So I think a checkbox in the "Add text or variable" step saying "insert at the beginning" would be great!

This might even be handy for Markus ...

Stef

Mario

Quote from: stahl on April 23, 2019, 07:46:13 PM
Thank you, Mario!
I thought it over: I think what I need is the ability to insert text/variables before the bits of text that previous steps in the renamer have already created (right now I can only insert at the end):

1. Add text or variable: {file.name}
2. Replace before "-" with ""
3. Add text or variable at the beginning: newname ...

So I think a checkbox in the "Add text or variable" step saying "insert at the beginning" would be great!

This might even be handy for Markus ...

Stef

Se my info about "Replace before" and "After steps" above. I won't make any other changes to the Renamer for now.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: stahl on April 23, 2019, 07:46:13 PM
Thank you, Mario!
I thought it over: I think what I need is the ability to insert text/variables before the bits of text that previous steps in the renamer have already created (right now I can only insert at the end):

1. Add text or variable: {file.name}
2. Replace before "-" with ""
3. Add text or variable at the beginning: newname ...

So I think a checkbox in the "Add text or variable" step saying "insert at the beginning" would be great!

This might even be handy for Markus ...

Stef

I personally could and and can solve all renaming with the renamer, like it is now.
With the new changes from Mario you will be able to solve at least all your wishes, what you have described here.

If sometimes something is not solvable in one step, we can find a solution in two steps.

Of course it is also depending, how many images are to rename (100 or 10'000).
Best wishes from Switzerland! :-)
Markus

sinus

Just a quick peek.
You could also solve your problem with the renamer as it is NOW.

If you use Regex, all picturenames names WITH codes (-e2f...) will be replaced correctly.

See my attachement.

The pictures without a code behind are NOT replaced, so in a second step just DO search all pictures with no "newname" and then replace the whole filename with "newname" and then everything is as you want it to be.

Maybe you can combine these 2 steps in one, I haven't looked any further.
Best wishes from Switzerland! :-)
Markus

stahl

Ha, solved!
Thanks Markus, you pointed me in the right direction! In fact, Renamer can solve the challenge quite elegantly as it already is now:

To add the suffixes of the old file name to the new file name you are building in Renamer, do
1. Text and Variables: § (or any other obscure character that you will never ever have in your file names)
2. Original File Name
3. Remove Text: §[^-]*, checkbox "Regular Expression" checked

This will
1. add "§"
2. followed by the original file name and will then
3. delete "§" and anything therafter until the first "-"

If there is no "-", meaning no suffix, the steps just have no effect. See also the attached screenshot.

Thanks a lot, Mario and Markus! Great programme and great support.
Stef

thrinn

Thank you for sharing your solution! I already bookmarked your post. This looks like a candidate for the Tips & Tricks section  :)
Thorsten
Win 10 / 64, IMatch 2018, IMA

sinus

Thanks, Stef, for your final steps sharing!
Cool, that it works  now.

And Thorsten, yep, maybe a good idea.
Best wishes from Switzerland! :-)
Markus

stahl

Good idea. I will do this when I find the time in the next days.
Stef