Button to rename folder

I want a button to rename a folder
Hello 12 (34-56)
to
Hello 12 (35-56)

Do you mean like in

rename "Hello 12 (34-56)" to "Hello 12 (35-56)"

?

Or rather incrementing that part in general?

1 Like

sorry, +1 with every click of course

It’s still not clear exactly what you need, with only one example to work from.

Increment the second number?

Or the first number in brackets?

Or something else?

the first number after the opening bracket.
In my example: 34.
The first number (12) and the last number (56) should not change.

Hello 12 (34-56)
click
Hello 12 (35-56)
click
Hello 12 (36-56)

Try

// https://resource.dopus.com/t/button-to-rename-folder/50395

@nodeselect

=re = "(.* \d\d \()" + "(\d+)" + "(-\d\d\).*)"
=s  = Stem(file)
=p1 = RegEx(s, re, "\1")
=p2 = RegEx(s, re, "\2") As int
=p3 = RegEx(s, re, "\3")

=(KeyDown("ctrl") && p2>0) ? p2-- : p2++

Rename TO="{=p1+p2+p3=}" IGNOREEXT
XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>50395</label>
	<icon1>#newcommand</icon1>
	<function type="normal">
		<instruction>// https://resource.dopus.com/t/button-to-rename-folder/50395</instruction>
		<instruction />
		<instruction>@nodeselect</instruction>
		<instruction />
		<instruction>=re = &quot;(.* \d\d \()&quot; + &quot;(\d+)&quot; + &quot;(-\d\d\).*)&quot;</instruction>
		<instruction>=s  = Stem(file)</instruction>
		<instruction>=p1 = RegEx(s, re, &quot;\1&quot;)</instruction>
		<instruction>=p2 = RegEx(s, re, &quot;\2&quot;) As int</instruction>
		<instruction>=p3 = RegEx(s, re, &quot;\3&quot;)</instruction>
		<instruction />
		<instruction>=(KeyDown(&quot;ctrl&quot;) &amp;&amp; p2&gt;0) ? p2-- : p2++</instruction>
		<instruction />
		<instruction>Rename TO=&quot;{=p1+p2+p3=}&quot; IGNOREEXT</instruction>
	</function>
</button>

Pressing Ctrl while clicking will count down.

2 Likes

Thank you very much, you helped me a lot.
Small change:
...
=re = "(.* \d+ ()" + "(\d+)" + "(-\d+).*)"
...