Opus scripting is horribly complicated

I'm a software developer and have seen my share of scripting environments, but Directory Opus is being exceptionally subborn for me get working.

Is there documentation on how the scripting system works? The help file spells out all of the commands I can use, but I find it doesn't really tell me how to write scripts to do what I want.

It's taken me half a day to get a seemingly simple script running. I'm sure in the future I'll get better at it, but I'd like to complain to someone that the learning curve is quite steep and my first impressions are that this it is just not very productive.

Some of the issues I've encountered are:

  • confusion with order of execution and multiple versus single execution
  • differences between internal, external and batch commands
  • lack of feedback running scripts (nothing seems to fail no matter what I type in - it just fails to do what I expect)
  • odd modifier syntax
  • clumsy control codes (examples: {allfilepathshort$} and {sourcepath|nopath}

I'm starting to think the easiest thing for me to do is to run the following external command to run a script:

@runonce: perl myscript.pl {add dopus arguments here}

All the available documentation is either in the manual or in the tutorials section, plus the various button examples posted throughout the forum.

Note: User-run support community for GPSoftware's Directory Opus.

Out of curiosity, who pays for hosting this site? I've always wondered.

GPSoftware pay for the bandwidth but Steve runs the site.

Some thoughts in a bit more detail:

The Command Control Codes section of the manual should explain what will happen. It's not that confusing: If you have multiple files selected and use codes which only insert a single file into a command line then that command line will be run multiple times, once for each file. If you don't then it won't.

(If you have specific examples which don't follow that pattern then post them here and I'll take a look at them.)

They're different because, well, they're inherently different. How could they all be the same? If you don't like the differences then you can stick to only using one type of command.

Think of calling an external command-line program from Opus like calling an external command-line from a Perl script: Of course it'll behave differently to internal Perl functions.

Actions which are valid but which fail (e.g. trying to overwrite a file that's in use) will produce error messages so I presume we're not talking about them.

I agree that Opus could do a better job of helping with completely invalid commands instead of skipping them.

On the other hand, I think a bigger problem is commands which you think will do one thing but which another because of a misunderstanding. In that case there's no error message since, as far as Opus is concerned, it did what it was asked to do. That's the same as any other language, though. There's no way for the computer to know you really meant something different.

You can use the Log window in Opus to get an idea of what's actually going on. If you're creating DOS batch buttons then putting "echo" before each line is also a good aid to debugging and the doptest tool in the Tools forum is a similar helper for non-batch buttons.

It is unusual (unless you grew up with an Amiga) but it's also very succinct, telling you how to use each option with (usually) only two extra characters after the name. Once you know what the characters mean it's a lot quicker to read things like

...,FILTER/O,FORCE/S,...

than things like

...,FILTER (option), FORCE (switch),...

At least, I think so, when the command takes a long list of arguments.

Reading the short portion at the start of the Opus Raw Commands chapter and looking at a couple of examples should remove any confusion about what the modifiers mean:

[ul][li]/S Switch. Indicates a binary switch qualifier. The switch will be set if the option appears in the command-line.

/O Switch with optional arguments. The same as /S but takes optional arguments where the default action can be modified. For example, Copy takes an option UPDATEEXISTING, which may have none, size or date as a qualifying parameter.

/K Keyword. This means that the option will not be accepted unless the keyword appears. For example if the template is "Name/K", then unless "Name=" or "Name " appears in the command line, Name will not be accepted.

/A Required. This keyword or a value for it must be supplied, or else the entire command line will be invalid.

/M Multiple strings. This means the argument will take any number of strings. Any arguments not considered to be part of another option will be added to this option.[/li][/ul]

I guess they could be more uniformly named/modified.

There's might be a case for making less commonly used things like {filepathshort} into {filepath|short} -- i.e. having a "|short" modifier which can be added to the more generic codes instead of additional codes for the short paths. I don't think there are so many of them that it makes that much difference, though.

$ at the end always means a code is required ("need" rather than "want"). Provided you've looked at the Command COntrol Codes section of the manual once to know what it means I think that the $ is good as it's very common to use both the "need" and "want" variants of the codes so it's good to have the difference between them short and easy to see.

"|nopath" is rarely needed but I guess there's a case for having a separate {sourcename} or something instead of {sourcepath|nopath}. That would be more uniform.

[quote]I'm starting to think the easiest thing for me to do is to run the following external command to run a script:

@runonce: perl myscript.pl {add dopus arguments here}[/quote]

I imagine it took you a lot longer to learn Perl's often cryptic syntax than it will take to get used to Opus's syntax. We're talking about a language which uses the same symbol for pointer dereferencing as it does for code blocks and is known for programs which look like line noise.

Give the Opus commands a bit more time and you should find there are only a few concepts and warts that need to be dealt with.

At the same time, when you want to do something really complex, particularly with branching and conditional logic, then there's absolutely nothing wrong with calling scripts in other languages from Opus. I do that in a few cases. Opus doesn't try to provide a full scripting language; just a basic way to chain some of its commands together or customize what they will do when run in addition to a way to pass arguments to external programs and scripts.

Thanks Leo for spending some time to discuss Opus scripting. I don't think this stuff will ultimately deter me from purchasing it. But if I do, I'd like the developers to know what I consider some weaknesses of the product.

I think a better manual would help here, but I also think a more explicit command set would also clear up confusion. I think a foreach construct would be a better idea than having hidden execution rules.

Thanks, I'll look into the log window and doptest next time.

Actually I was talking about the command modifiers, the @xxxx directives. I'm happy with the general command syntax, but maybe that's because I grew up with Amigas (500 and 3000). It's just that the shell is no ARexx. The other stuff doesn't seem as well though out as the command set.

Yes, yes, this is exactly the sort of thing I was thinking but didn't elaborate on it.

Yes, but Perl is a wonderful language for simple things and it is worth the effort.

Yes, I'm sure I will get a handle on it soon enough, but I think the scripting is still overly complicated for your average Joe trying to automate a task.

Hi guys,

i'd like to drop in and add my little view to the scripting and automation part in dopus.

I'm some kind of a little scripting "expert" too, i even make money with software developing and stuff.. (not that i could code somehting like DO, but smaller tasks are just fine.. o).

And i agree with Ross, who has his difficulties. I also have problems getting DO to do what I want. It's not that I do not understand the manual or raw-cmd syntax. It's more like handling variables and passing values from one command line to the next. Or the next stage - conditional execution.

Something like:
if (isAnyJPGSelected()){
moveAndEXIFRotate();
}
if (isAnyMOVSelected()){
moveAndConvert2MPG();
}

Two different actions for two different filetypes.. I got this while I was putting up some automation for reading out and automatically moving the content of the sd-card from my digital cam. That's just to give an example, I do not ask for a solution here.

And in a case like this, as Ross mentioned.. you could easily go and run your favourite editor and write your perl- or js- or whatever script, which then does what you want.

Am I asking to much ?! Is it my fault ?! Are "more specific" tasks, not to be done by DOs internal scripting ?! I really doubt it, especially as I make use of the rename-scripting, which is kind of a dream! I whish there were more corners, where DO would be scriptable like this.

All the commands in DO are so powerful and configurable, it's a shame I am just unable to combine them nicely. To me, it's seems as there is some "glue" missing, that wraps all these environments, syntaxes and internal/external commands together. Apart from that, I admit that I perhaps did not dig deep enough in this forums, manuals and help-files. I do a lot, I come here and read and try and just to learn. This automation-topic in DO is kind of hard to me, sadly I don't exactly know why.

But I like DO nonetheless, couldn't make it without!
greetings.
rob.

[quote="tbone"]Something like:
if (isAnyJPGSelected()){
moveAndEXIFRotate();
}
if (isAnyMOVSelected()){
moveAndConvert2MPG();
}[/quote]

If you want to do conditional stuff with subroutines like that then you should use a scripting language (which could be in an Opus rename script if you want; they don't have to be used just for renaming).

Opus's command language is not supposed to be a full scripting language. It isn't meant to replace Perl or Ruby or VBScript. It's just there to let you launch internal and external commands and pass arguments to them, really.

There is some support for variables -- only added to allow you to request an input from the user once and then insert it into multiple lines without requesting it again and again -- and some very limited types of conditional execution (e.g. running different commands if ctrl, shift or alt are held down) but that's about it.

Despite that, it is still very powerful and suitable for most tasks. When you need to do something complex, though, then you are better off using a scripting language. Opus makes it very easy to pass the selected files to a script (either via a Rename script or via simply calling the script on the command line) and once your script has the file paths it's free to do whatever it wants to them.