Variables and DOS windows

With the change in 9.0.0.7 that Steje mentions, hopefully @sync is a thing of the past. :slight_smile:

The MultiListers tutorial can be downloaded in a zip file if you don't want to view it online. It's 8.5MB in size so not too bad over dialup I guess. Unless it's really slow dialup. :slight_smile:

For batch image conversion Opus has some built-in functions for doing the basic stuff like resizing and converting to JPG/BMP/GIF/PNG. For doing more advanced things Opus works really well as a front-end to command-line tools like ImageMagick. (There's another good, free command-line image tool but I can't remember the name of it.)

[Encode/Transcode selected WAV/MP3 files to MP3 using LAME - #3 by BenjaminW)

id3cp would copy every ID3 Tag from any file format I think (you can even copy the ID3 Tag to an empty file which is like a backup :wink:). But I don't know wether ogg/flac use these. I have compiled id3cp from the id3lib package. It was a simple example in it.

Greetings
Ben

Thanks Benjamin. I will try it. It will only (probably) work with ID3 tags, but that is a start.

Some gui-based taggers provide functionality to copy tags universally. Maybe I can find one which supports command-line uhm, commands. :smiley:

Thanks,

Bob

I've tried... TGF and Mp3tag are two pretty good free taggers, and neither of their devs seeme interested in command line or api interfaces.

I expect they feel they put too much time and effort into their UI...

i am using this code for doing transcodes that fit my needs, and it has been getting the job done:

@nofilenamequoting CreateFolder tmp READAUTO=no C:\Program Files\Utilities\lame.exe -b 160 -m j --resample 44.1 "{f}" ".\tmp\{o|ext=mp3}" C:\Program Files\Utilities\id3cp.exe "{f}" ".\tmp\{o|ext=mp3}" Copy MOVE FILE FORCE File ".\tmp\*" TO .\ Delete QUIET tmp

the problem i have run into is that occasionlly, if there is some sort of error and the process quits before finishing, i get left with files that either haven't been transcoded, or if they have, they no longer have any tags since that is one of the final steps. unfortunately, this happened to me near the end of an albums worth of music, so i lost the tags and covers for around 18 of 21 files, and the one it was currently processing was ruined.

a second issue that i have run into is that if i run a search in a folder (with subfolders) and then try to select the results and transcode them with the button, it can't do it. i assume this is because it would normally create the "tmp" folder in the current folder and the files are not technically all in the same folder.

i was wondering was if the coding could be reworked so that new file is created in the same folder, perhaps renamed to have a "~" at the beginning, and then have have the tag copied over, the original deleted, and the "~" removed before moving on to the next file. that way, if something interupts the process, only one file is lost (or needs to be recovered). i would think that would also me to process files in the "Find Results" window.

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. :slight_smile: )

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. :slight_smile: 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.