Concerning the Rename topic I know there are tons of presets available, still I am missing a fairly simple one where you can start a numbering sequence using a template with right filename and starting number, something like
By the way ACDSee and Everything are providing it and I am fairly convinced that DO can do it as well. I just don't see how and I'll appreciate if somebody can oriented me in the right direction without suggesting a too complicate RegEx or a cryptic script that I am not conformable with.
Leo
June 10, 2022, 4:11pm
2
The Sequential Numbering checkbox in the rename dialog lets you do that.
lxp
June 10, 2022, 8:52pm
3
Take a deep breath and try
// https://resource.dopus.com/t/rename-using-template/41439
// 2022-06-10
function OnClick(clickData) {
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
cmd.deselect = false;
if (tab.selected.count == 0) return;
var item = tab.selected(0);
var part1 = item.name_stem.replace(/(.*_)(\d+)/, '$1');
var part2 = item.name_stem.replace(/(.*_)(\d+)/, '$2');
var cmdLine = ('Rename ADVANCED PATTERN="*" TO="' + part1 + '[#]" NUMBER=' + part2);
// DOpus.Output(cmdLine);
cmd.RunCommand(cmdLine);
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" textcol="none">
<label>41439</label>
<icon1>#newcommand</icon1>
<function type="script">
<instruction>@script JScript</instruction>
<instruction>// https://resource.dopus.com/t/rename-using-template/41439</instruction>
<instruction />
<instruction>// 2022-06-10</instruction>
<instruction />
<instruction>function OnClick(clickData) {</instruction>
<instruction> var cmd = clickData.func.command;</instruction>
<instruction> var tab = clickData.func.sourcetab;</instruction>
<instruction> cmd.deselect = false;</instruction>
<instruction />
<instruction> if (tab.selected.count == 0) return;</instruction>
<instruction />
<instruction> var item = tab.selected(0);</instruction>
<instruction />
<instruction> var part1 = item.name_stem.replace(/(.*_)(\d+)/, '$1');</instruction>
<instruction> var part2 = item.name_stem.replace(/(.*_)(\d+)/, '$2');</instruction>
<instruction />
<instruction> var cmdLine = ('Rename ADVANCED PATTERN="*" TO="' + part1 + '[#]" NUMBER=' + part2);</instruction>
<instruction> // DOpus.Output(cmdLine);</instruction>
<instruction> cmd.RunCommand(cmdLine);</instruction>
<instruction>}</instruction>
</function>
</button>
Don't worry, the preview window will allow you to cancel, if you don't like the results
This post explains how to add buttons to toolbars and menus, and also applies to raw commands for things like standalone hotkeys.
For how to use Script Add-Ins, please scroll down to see the post below this one.
Much of this assumes Directory Opus…
AWESOME (almost)! It does work in most cases, except when the number in the template is precede by a space:
OK
I can live with that , but unfortunately the not working case is the one I use the most.
Remediable?
Thanks by all way
Sorry, this is the not working case:
lxp
June 11, 2022, 6:23am
6
zarkikunet:
Remediable?
Sure
Just remove the underscores like this:
var part1 = item.name_stem.replace(/(.*)(\d+)/, '$1');
var part2 = item.name_stem.replace(/(.*)(\d+)/, '$2');
So obvious. Still, you remain all remarkable. Many, many thanks