How Opus decided how many times an instruction is executed from a Command object?

I’ve noticed something where I can’t find the decision pattern Opus follows. Although this behavior doesn’t seem exclusive to scripting—it also happens when using instructions in buttons, etc.—I’d like to focus on its use via scripts, as that’s my specific case.

When an instruction is executed from the Command object that already has a certain number of files loaded, some commands are executed repeatedly for each file (this usually happens with internal commands), while others are executed only once (usually script commands), regardless of the codes used to pass files.

For instance, if I run something like:

Command.RunCommand('COPY "{filepath}" COPYTOCOLL=member CREATEFOLDER="coll://cmdtest" WHENEXISTS=skip')

It executes for each file in Command.files. However, if I run:

Command.RunCommand('cmd2 {filepath}')

It only executes once, using the first file.

According to the manual, using {filepath} implies the command should execute repeatedly for each file, whereas {allfilepath} executes only once. Is that correct?

Ideally, Opus should apply the same rule for script commands and handle this internally when the instruction is executed.

Here are two commands if you ever need a quick testing:
cmd1.opusscriptinstall (953 Bytes)
cmd2.opusscriptinstall (900 Bytes)

  1. Select some files.
  2. Run cmd1.

You'll notice that cmd1 copies all the selected files to a collection, but it only run cmd2 once for the first file.

What would be the most appropriate way to execute instructions?
Should I manually check if the instruction contains {filepath} to decide whether to use a loop?

TIA