Renamer with variables doesn't work for my file names

Started by ben, December 30, 2018, 06:08:21 PM

Previous topic - Next topic

ben

Hello everyone,

i tried around a specific renaming problem for the last 2 hours and don't get to a result.

I am trying to rename files of the following format:
   yymmdd_<string>_xxxx.jpg
to
  yymmdd_xxxx_<string>.jpg


Wheras:
  yymmdd: date, 6 chars long
  <string>: a string of 2-15 chars
  xxxx:       trailing number, 4 chars long


I tried several variable combinations in the Var-Toy, but i am stuck.
I think the problem is, that i don't know the lenght of <string>

Any ideas of someone who has done these kind of things??

Thanks a lot in advance,
Ben

stephock

Is the trailing number already part of the file name, or will it be generated?

ben


Mario

This seems like you want to slice out a piece of variable length from your file name and then insert it at a different place of your file name.
Probably something that can be done with a regular expression only, looking for the terminating _ and _ surrounding the variable length text...
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

JohnZeman

I've been trying to solve this too using a regular expression with the Replace Text instruction but the only RegEx that seems to work at all for me is to replace all file name text with something else.

For example

Find (.*)
Replace with TEST

Works for me but any other RegEx results in an error.

Mario

Find(.*) is something you are using in the Renamer...?
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

JohnZeman

No you're right Mario, it's Replace not Find.  I was testing the regex in other programs to test my regex to make sure it worked in those programs and in those they call it "Find".

Below is a screenshot of what I'm doing in the IMatch renamer.

Mario

IMatch uses PERL syntax for regular expressions. You can use the RegExp tester app to see if your regexp grabs the right content.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

Ok, thanks. It seems there is no easy solution, so i just keep the filenames. That's fine.

Is it possible to use "|substr" in combination with"length"?
It didn't work for me.
This way i could calculate the length of the variable part.

Is it possible for one step of the renamer to use the result of the previous step?
This would make it easy as well.

Ben

sinus

Quote from: ben on December 30, 2018, 09:40:56 PM
Ok, thanks. It seems there is no easy solution, so i just keep the filenames. That's fine.

Is it possible to use "|substr" in combination with"length"?
It didn't work for me.
This way i could calculate the length of the variable part.

Is it possible for one step of the renamer to use the result of the previous step?
This would make it easy as well.

Ben

Ben,
try something like this, see attachement.
You must only change the first and last characters correct (6 and 4 chars), I had not the time.

works here.
Best wishes from Switzerland! :-)
Markus

Mario

Quote from: ben on December 30, 2018, 09:40:56 PM
Is it possible for one step of the renamer to use the result of the previous step?
This is the normal behavior. Each step 'sees' the output of the previous step.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

I tried again (was again on my computer, at random) my prefs for the renamer with your name-system, Ben.

And here it works, like it should, with one preset.
See attachements, first your naming-system.
The prefs for the renamer.

And the final name, changed with your new system (what I think, is better, having the unequal length of the text at the end of the filename, I do it like this).
Good luck.

Best wishes from Switzerland! :-)
Markus

JohnZeman

That's a nice solution there Markus, I hadn't thought of solving Ben's problem that way.

I'm going to file this little tidbit of information away in case I ever need to do some renaming like this.

sinus

Quote from: JohnZeman on December 31, 2018, 04:45:43 PM
That's a nice solution there Markus, I hadn't thought of solving Ben's problem that way.

I'm going to file this little tidbit of information away in case I ever need to do some renaming like this.

Thank, John
for your nice words!
I hope, you (and all others) will start the new Year very relaxed and with beautyful feelings!
Best wishes from Switzerland! :-)
Markus

ben

QuoteBen,
try something like this, see attachement.
Sinus, thanks so much!! Worked like a charme.

I read through the help page several time, but only now that i know how to do it, i found the right paragraph.
Formatting arguments are specified as key:value pairs after a separating pipe | character. The general syntax is:
{Variable|key:value; key:value; ..



Can you have a look at the following code as well?
This should work as well, shouldn't it? But according to the Var Toy App it doesn't.
{File.Name|substr:7,{File.Name|length;cast:int;math:sub,12}}

Have a great new years eve!!