Some bugs with buttons and rename?

I've made a button that does the following:

  1. convert underscore to space using FINDREP
  2. Remove brackets (and any text inside them) with REGEXP
  3. Remove any spaces preceding the filename with REGEXP
  4. Remove any spaces between the filename end and the extension using REGEXP. For example "file name 01 .zip" would be converted to "file name 01.zip"

Okay, so far so good. But only three of the commands seem to work properly. When the time comes to do rename command number four, the program says "invalid filename" and shows the ORIGINAL file name that was before any of the button's commands were applied. The first three commands are executed properly and if you click abort after the error message and press the button again, the fourth one is correctly executed as well.

So is this a bug or am I doing something wrong? I tried doing it another way (remove any spaces before and after a bracket with FINDREP "] " -> "]" and " [" -> "[") but again I get the same error. Using just three commands seems to work fine.

Now, I also spotted a few definite bugs:

  1. Editing a button the ] key causes an error message ("only these keys can be used blahblah), but copy&pasting it works fine.
  2. If you paste something with regular expression commands (for example (.*) or something) to the Old name line in Rename with REGEXP the CPU usage goes to 100% and I have to kill the dopus process.

I've seen what you describe as well when trying to chain several renames in a single button. I guess it's a bug, or at least undesireable behaviour.

There are a couple of workarounds:

  1. The obvious one, split the command into multiple buttons. (Three-buttons help here since they avoid clutter and mean you can left, then right click the same button.)

  2. The less obvious one, use dopusrt to run each rename as an external command. Since each command will run independently of the others Opus will correctly apply the second rename to the results of the first, and so on.

For example:

dopusrt /cmd rename <1st rename args here>
dopusrt /cmd rename <2nd rename args here>
dopusrt /cmd rename <3rdrename args here>

It's worth reporting this issue, and the other two you mention, via the support form so they're added to the bug database.

Tried doing them with dopusrt but it seems the commands do nothing.
The button commands looked like this:

Rename PATTERN="_" TO=" " FINDREP
Rename PATTERN="(.)[.](.)#" TO="\1\2" REGEXP
Rename PATTERN="^( +)(.
)" TO="\2" REGEXP
Rename PATTERN="(.[0-9])(\ .)(..*) TO="\1\3" REGEXP

The fourth one being the one that doesn't work.
So I changed them to dopusrt /cmd rename PATTERN="...etc, is this correct?

You're right, I tried it out and the problem is that each rename deselects the files that it applied to, so subsequent renames don't affect all of the files.

I tried adding dopusrt /cmd select reselect between each line but that doesn't work because while it selects the files which were affected by the previous rename, it also deselects those which were not.

If you're going to be renaming all files in a given directory then you could use dopusrt /cmd select all between each line but that's all I can think of.

Will that @NODESELECT option help here?

Hmm... You couldn't use @NODESELECT directly since it has to be on a line by itself and it would need to be applied to each of the dopusrt rename lines, rather then the button as a whole.

As far as I know there's no way to send a multi-line command to dopusrt directly...

But there is a workaround...

You can create a User command for each rename line. For example, create a Rename1 command which does

Rename PATTERN="_" TO=" " FINDREP
@NODESELECT

Make Rename2, 3 and 4 similarly.

Now you can make a button which runs each of these via dopusrt:

dopusrt /cmd Rename1
dopusrt /cmd Rename2
dopusrt /cmd Rename3
dopusrt /cmd Rename4

I just tried this using kasakka's four rename patterns and I'm happy to say it works! :opussanta:

By the way, the 4th rename command in post #3 is missing a quote at the end of the pattern argument. You'll need to fix that else it will cause the Rename dialog to appear.



Thanks for the help, I'll give that a try. The 4th one was missing the quote simply because I typed it while the others were copy&pasted..

Right, converted the renames to user commands, added @NODESELECT and made the button use the dopusrt /cmd stuff. Seems to work fine on single files, but with multiple files I still get the same error and usually the last rename command is not applied, sometimes the one before it (removes the leading space from the filename) isn't applied either on all files.

I've had pretty good luck combining multiple lines of RegEx and non-RegEx renaming in a button by using

GO REFRESH
SELECT ALL

in between each step of the renaming process. True, all the files and folders are selected each step of the way however depending on how you write your RegEx you may be able to only rename the files you want renamed leaving the others alone. If that's not practical, you could temporarily move all the files you want to rename into a temp folder (or otherwise filter them so only the files you want are visible) and then run the button across all the names.