Collections & flat view
Using .\ doesn't make sense in Find Results since the current directory isn't a real directory (it's the Find Results collection). Using .\ in flat-view will work, though, but it will always point to the lister's current directory, not the directory of each file.
Instead, you can use codes like {f|..} to get the parent of each file. That can be useful when dealing with files in collections and flat view.
I would avoid creating the tmp folder at all and, as you say, use a temp file with a slightly different name. You can use ~{f} to put a ~ at the start of the name. (I guess you still need to be careful in case there's already a file that happens to have that name.
)
Execution order
Any line which inserts a single file will be run multiple times if multiple files are selected. So your command will run this if file1, file2, file3 are selected:
(I've simplified the commands so it's easier to read.)
[code]CreateFolder tmp
lame.exe file1
lame.exe file2
lame.exe file3
id3cp.exe file1
id3cp.exe file2
id3cp.exe file3
Copy tmp* to .
Delete tmp[/code]
If you want the entire command to run for each file before moving on to the next one then you will need to move it into either an external batch file or into an Opus "user command".
You could also put it into a rename VBScript but that would be overkill in this situation so let's ignore that option.
Opus user commands are usually convenient, since everything remains part of your Opus configuration, but in this case I would use a DOS batch file because of the next part:
Error handling
You need to add some flow control to catch errors and deal with them appropriately. Opus commands don't have flow control so you need to move the command into something that does and have Opus call that.
There are lots of options here but in this case using a DOS batch file makes the most sense.
I am assuming that lame.exe and id3cp.exe both set the DOS error code on failure. If they don't then there is no easy way to detect when they go wrong. (With lame.exe you could check for the existence of the output file to detect some errors.)
You can call Opus commands from batch files but, since you're only using CreateFolder, Copy (Move) and Delete there isn't much point in this case; might as well use the DOS commands instead and keep the batch file simple.
In a batch file you can use %1 and %2 to get the first and second arguments, so your batch file would probably look something like this (NOT TESTED):
[code]@echo off
"C:\Program Files\Utilities\lame.exe" -b 160 -m j --resample 44.1 "%~1" "%~dp1~%~n1.mp3"
if errorlevel 1 goto cleanup
"C:\Program Files\Utilities\id3cp.exe" "%~1" "%~dp1~%~n1.mp3"
if errorlevel 1 goto cleanup
del "%~1"
ren "%~dp1~%~n1.mp3" "%~dpn1.mp3"
goto end
:cleanup
del "%~dp1~%~n1.mp3"
:end
[/code]
(See part 9 of Top 10 DOS Batch tips to understand what all the %~dp1 junk means.)
You would then call this batch file from an Opus button, once per file, giving it the path to each file:
"C:\Wherever\You\Put\It\MyBatchFile.bat" {f}
Alternatively...
Having said all of that, I'm going to suggest you don't do any of it.
You can do all of this much better by using a tool that is designed to transcode audio and copy the tags over. I recommend using dbPowerAmp Music Converter (dMC), though I think you may have to pay to get the version that can output MP3 so you might want to explore other options if you want something free.
dMC will convert music from just about any format into just about any other format and it will copy all the tags and cover art (at least for any pair of formats I have tried which support tagging).
You can use it in Opus via the context menus and I find it integrates very well.
It will also encode multiple files in parallel if you have more than one CPU (at least with the non-free version).
And you get a nice overall progress bar and error reporting, unlike when running DOS commands.