Pausing in a multi-function button

I use the TitleCase program from the download area and I love it. I've also written a renaming button using Opus functions that will take an mp3 file from my collection and, if it starts with "The" or "A," it will put that at the end of the filename. Example: "The Ocean.mp3" becomes "Ocean, The.mp3". Now I'm trying to combine both into one button. It's not working so well.

When I select a file and click on the combined button, TitleCase is supposed to run first, then the renamer is supposed to run. The problem is that TitleCase is not being given a chance to actually be called and run on a file before the renamer kicks in. Example: running the combined button on "The Song Remains The Same.mp3" results in "Song Remains The Same, The.mp3" and an error message from TitleCase because the filename that got passed as the argument no longer exists (because the renamer has already changed it). Running the combined button on a file that doesn't start with "The" or "A," and thus wouldn't be changed by the renamer, produces the correct result.

Is there a way to insert a pause into the button's code, which will allow TitleCase enough time to run to completion, and then continue with the renamer? I'd really like to combine both funtions into one action. Any ideas?

Here's how the button is currently set up:

<?xml version="1.0"?> Music Rename Places "The" and "A" at the end 154 Rename PATTERN="(.*)(- [0-9][0-9] - )(The |A )(.*)\.(.*)" TO "\1\2\4, \3.\5" REGEXP @NODESELECT Rename PATTERN="(.*)(\ \.)(.*)" TO "\1.\3" REGEXP


Hey chris... I haven't looked at titlecase, but where in your button above are you actually running it, am I missing it?

But in general, you can prefix sync:dopusrt /cmd to each your buttons functions in order to make sure that a given command completes on the file before the next command is run. I 'think' that should help you...

No, you didn't miss it. I had been tweaking and trying some things before I wrote the note, and I'll be darned if I didn't copy the button info without the TitleCase function in it. Sorry. That was pretty stupid. There are two more lines before the RENAME function:

runmode hide
D:\Dos\TitleCase.exe {filepath}

Those are the two lines that run the program.

I'll try the "sync:dopusrt /cmd" thing. So, if I understand the manual correctly, that will make the two "rename" functions act as if they are external, rather than internal, commands, and therefore they should wait for the first program to run to completion before beginning the next. Is that about it?

I'm sorry, but I'm not at my primary computer right now, and won't be until sometime tomorrow, so I'll test the theory then. Thanks for the thought!

--chriscrutch :confused: :confused: :confused:

Hey chris - no worries on when you try it out :slight_smile:...

edit - oops, premature submit.

About the command prefix:
Basically yes, but specifically... the sync: portion of the command prefix is what actually causes the commands to run 'in order' one finishing before the other, but I guess is ONLY an option for 'external' programs like TitleCase, and not 'internal' Dopus functions like Rename.

The dopusrt /cmd portion of the command prefix makes internal Dopus functions run within Opus as if they were external programs.

So combining the two together lets each Dopus command run 'in order' - one finishing before the next starts. I believe you might need to prefix the call to titlecase.exe with at least just sync: for it to all work properly...?

Hi Steje,

I have a diferent understanding of this.
sync: causes the commands to be started synchronously ( in time order ).
It's been my understanding that there in no absolute exit code before the next line starts.
It's a hit or miss situation.

GPSoft, please correct me on this if I'm wrong.
A clarification of this would help all.

:opusicon: porcupine

edit note:
I just created a button the runs a program that lists all the files and Dirs in a directory.
I used the program twice, once on the first line and once on the second line.
I then wrote Sync: dopusrt /cmd at the beginning of both lines.
I went to a directory that contains 4096 files and pressed the button.
Two Dos windows appeared one after the other.
The first window was not even close to finishing before the second began executing its' code.

However if I use just sync: the first program executes to completion and then the second program executes.

So I guess you're right Steje.

I'm going to have to agree with porcupine on this one. When I add "sync:dopusrt /cmd" to all functions, they all try to run at the same time. The result is an error by TitleCase, the first renaming function running correctly, and the second renaming function (to take out the space left by moving the "The") doesn't work. It seems to me, then, that all three functions are happening simultaneously.

When I only add "sync:" to all functions, TitleCase runs properly, but neither of my renaming functions do, because I get an error saying that Windows cannot find the program "rename." That shows me that "sync:" is only for external commands, like steje said.

So, when I prefix the external program call with "sync:" and the internal Opus calls with "sync:dopusrt /cmd", I get the error from TitleCase, but neither rename function runs.

When I put no prefix on TitleCase, but "sync:dopusrt /cmd" on the internal commands, TitleCase runs properly but the internal renames do not.

When I prefix only the TitleCase call with "sync:" (and the internals with nothing) both the internal renaming functions work, but TitleCase does not (and does not produce an error...)

When I prefix all functions with "sync:dopusrt /cmd", only TitleCase runs, the internals do not.

So, basically, I have a way now to eliminate the error message from TitleCase, but the combined button still doesn't work. :confused: Heheheheheheh. Thanks for sticking through the explanation of all the combinations. Did I miss any? And although this isn't an official support mechanism, maybe someone from GPSoft could weigh in on this, for the enlightenment of all....please... :smiley: Anyone else, too, of course. Anyone with any ideas feel free to comment. Thank you all.


Hmmm... yeah well I guess I should have mentioned that I've had problems getting things to work how I think they 'should' work using these sort of combinations of external and internal commands. So - disregard my explanations as the nonsensible ravings of a lunatic mind...

But sure enough, for some reason... THIS series of commands does what I want:

sync:"C:\Program Files\Monkey's Audio\MAC.exe" {filepath} {filepath|ext=ape} -c5000 -v
sync:"C:\Program Files\Lame\Lame.exe" --alt-preset insane {filepath} {filepath|ext=mp3}

ALL selected files are FIRST converted by MAC one at a time and finish before all files then get encoded by LAME one at a time and finish, and then the Delete kicks in. In this buttons case, the button is set to run as Function type: Standard Function (Opus or external) which is the default function type I think.

I wonder if you'll get any different results if you change the function type to MS-DOS Batch Function???

I think this will work, but I haven't tried it.
This will run Mac and then Lame for each selected file.
I used a Dos delete here.

Call MacLame.bat {filepath} {filepath|ext=ape} {filepath|ext=mp3}


"C:\Program Files\Monkey's Audio\MAC.exe" %1 %2 -c5000 -v
"C:\Program Files\Lame\Lame.exe" --alt-preset insane %1 %3
Del %1


MacLame is just an MS Dos batch file.
There are many times a question is asked on this forum that a 4NT batch file can easily do,
but I keep quiet about it .
4NT batch files usually have the extension btm.
It is also possible to pause in a 4NT batch file using the Delay command.
Unfortunately the agument must be an integer number of seconds.

:opusicon: porcupine

As far as the MAC and LAME stuff I'm using - the way I run the button above works just fine in the way I was describing, so I don't need to change a thing... I'm good to go.

I was just wondering aloud if changing the Dopus function type for chris' button to MS-DOS Batch Function would change his results at all...

Hi Chris,

I'm having trouble getting your Regular Expressions to work.
Can you give me an example of a title that they work on and what the resultant title is ?
Also check to see that your reg exp syntax that works is the same that is posted.
I haven't worked through them as I'm really not up to speed on Dopus Regular Expressions at the present time.
I've used them in PHP, but not much in Dopus.

I tried to write a C++ program to execute them from inside the program.
If I can get the regular expressions working outside the program as you have them working,
there is a chance we can sync: ourselves out of this using the program instead.

:opusicon: porcupine

Accidentally posted twice. :frowning:

Thanks for the thoughts, guys.


switching to an MS-DOS batch function changed the results sometimes, but never to the point where the combined button functioned the way I wanted it to. I've actually got a little Excel spreadsheet that documents all the different permutations of using "sync:", "sync:dopusrt /cmd" on both the internal and external functions, and running them as Dopus commands or DOS batch commands. The best combination that I can get, as it seems now, is getting one of them to run properly and not return an error with the other. By "one" and "the other" I mean the rename by TitleCase and my regexp rename.


Not thinking that anyone would be writing a program specifically designed to meet my needs, I omitted some information for clarity and length's sake. The reason that you're not getting my regexp functions to work properly is because I use a certain method of naming my mp3 files, according to my personal preference. That convention is: - - - .mp3. An example, therefore, of a filename that would be affected by my regexp would be: "Led Zeppelin - Houses Of The Holy - 01 - The Song Remains The Same.mp3" The track numbers have to be in there for my regexp to work. The track numbers are what signal, in my naming convention, the beginning of the song title, which is all I really want my function to change. If I run my regexp on the above filename, I would get this: "Led Zeppelin - Houses Of The Holy - 01 - Song Remains The Same, The.mp3" Running TitleCase on the above filename would produce this: "Led Zeppelin - Houses of the Holy - 01 - The Song Remains the Same.mp3". If my combined button would work the way I had envisioned it working, it would result in this: "Led Zeppelin - Houses of the Holy - 01 - Song Remains the Same, The.mp3" In addition, (I'm sure you're doing this anyway, but just in case...) copy and paste my regexp function from the post into your copy of the function, don't try to type it. There are some spaces in there that are hard to see with the board's font, and the spaces are important. The second regexp is specifically designed to remove a space from the end of the filename that is a result of the first regexp.

Also, pardon my ignorance here, but the 4NT batch files that you mentioned, could something like that be used in my case?

I quite appreciate both of you guys thinking about this. Thanks again! :smiley:


To use your regular expressions in a batch file, you need dopusrt /cmd .
You may have to include the full path to your Dopus dir .

Almost certainly.
In fact, an MS Dos batch file may get it in this case.
4NT is expensive, but it's nice to have.
It is written by JPSoft .

I'll work on this later today Chris.
I have to put up a new clothes pole for my mom, then I'm doing a 6 mile hike.
Talk to you later.

:opusicon: porcupine

Well a couple of things,

So, the way MAC and LAME seem to exit is different from TitleCase, because sure enough the encode button I mentioned I use above works great, and encodes files one by one.

For chris' commmand, you probably want to insert an @NODESELECT after the call to titlecase, but it still really doesn't help :frowning:.

As an alternative to purchasing 4NT (Porc is right though - JPSoft makes GREAT stuff) you could run what you want to do in a 3 button Button where left mouse click runs the titlecase like so:

runmode hide
titlecase.exe {filepath}

...and the right mouse click runs the rename - by the way, if you're interested, I think you can strip the space after the 'The & A' chars with one command like so:

Rename PATTERN="(.)(- [0-9][0-9] - )(The|A)( )(.).(.*)" TO "\1\2\5, \3.\6" REGEXP

This way requires 2 clicks :frowning: - but at least on the same button.

Damn - ALMOST had it working in one messier button with the order of things swapped around a bit:

runmode hide
Rename PATTERN="(.)(- [0-9][0-9] - )(The|A)( )(.).(.)" TO "\1\2\5, \3.\6" REGEXP
titlecase.exe {filepath}
Rename PATTERN="
, the." TO ", The."
Rename PATTERN="
, a." TO ", A.*"

The problem is TitleCase is still running by the time the final rename commands to fix what it does to the ending portions of the filename run...

Maybe Tanis might be willing to make a change to TitleCase to exlcude patterns like ", The" and ", A" from the casing??? Then you could do it in one button like above without the final 2 Rename commands?


Thank you very much. I appreciate it. And I appreciate the tip about 4NT. I'll look into it.


I think I will use that new expression you gave me. Thanks for working the bugs out of that.

That problem you have with TitleCase still running...does it result in an error from TitleCase?

Putting the two buttons into a Three Button sounds like a good idea. It does require two clicks, but it's in one button, like you said. Failing to get it the way I'd like it, that's better than nothing.

If Tanis were to change the program, I would ask that he make sure that ", The" and ", A" get changed ONLY if they're at the end of the filename. Otherwise "The Wind, The Moon, And The Stars.mp3" (for example) wouldn't get properly cased.


Hey Porc - if Tanis doesn't have time to make any changes to the current TitleCase utility maybe the way to go is to write a new titlecase app? Wanna race - LOL?

Hi Steje,

I don't want to tread on Tanis's turf here yet.

I'm almost finished with a program to be used in conjunction with Tanis's .
All I have left to do is copy the old string to the new string, and rename the file.
I should be finished in an hour.
In the interest of speed, it operates on all the files in the source directory, instead of executing for each file.

:opusicon: porcupine

Hi Steje,

I've done it !!!
My program works in conjunction with titlecase.
sync: must be added to eash line.

It's fast Steje, very fast !
I need a beta tester or two .

:opusicon: porcupine