Help - Search - Members - Calendar
Full Version: Request: Batch file to extract CUESHEET+EACLOG?
Hydrogenaudio Forums > Lossless Audio Compression > Lossless / Other Codecs
Fandango
Hi,

I have several dozens of rips in which I embedded the EAC log and the cue sheet, and unfortunately I deleted all the original .log and .cue files. Now I want to have them back in order to back them up in archives for safe keeping.

So I've been searching for a windows batch file here that would make this task much simpler (drag'n'drop the audio files on the script), but without success.

I would like to write such a script myself, but I have no clue about windows command shell scripting, it's so different from unix shell scripting... mad.gif So if there's somone around who would be willing to write such a batch script for me (and for whom else it may be useful) that would be terrific!

IMHO these are some minimum criterias in order to make it easy to use:
  1. Batch script should create the cue sheet and eac log files with the same basename as the audio file. For instance the audio file is "Boards of Canada - 1998 - Music has the Rights to Children.wv" and the cue sheet would then be named "Boards of Canada - 1998 - Music has the Rights to Children.cue".
  2. If there's one of the two tags missing then creating the according file should silently be omitted. So a smart script that only does the things it is able to do without complaining about missing tags.
  3. A version that does the opposite would be nice, too: Embedding <basename>.cue and <basename>.log into <basename>.wv|ape|flac|[...]. Also only doing the things it can do without complaining, if there's only a log file only EACLOG tag gets written, and so on...
  4. works with multiple audio files
  5. I guess the tag.exe v2.0.46b1 is the tagger of choice wink.gif I've noticed some problems with the string "; " in EAC logs, which got fixed in that beta release.
  6. easy way to edit the paths to the executables and also the standard tag field names (I use CUESHEET and EACLOG by the way) at the beginning of the batch file

Cheers!
Fandango
It seems you can't display single tag fields with tag.exe, only all tag fields at once. Am I right?

If so, is there a way to / a NT command line tool around that will save the contents of single tag fields to an external file?

EDIT:

I just found out that Mp3Tag can be used for my task. This is even better than a batch script! Why haven't I thought about this in the first place?!? ohmy.gif

Anyway, it's as simple as writing an export configuration. This simple line here will do the trick for the EAC log:
CODE
$filename(log)$loop(%_path%)%eaclog%$loopend()

and
CODE
$filename(cue)$loop(%_path%)%cuesheet%$loopend()

for the cue sheet respectively. So far this only works with single selected files, but I'm sure I'll get it to work with a list of many files as well.

Piece of cake... laugh.gif
Synthetic Soul
QUOTE(Fandango @ Jun 4 2006, 17:39) *
I guess the tag.exe v2.0.46b1 is the tagger of choice wink.gif I've noticed some problems with the string "; " in EAC logs, which got fixed in that beta release.
Ah, yes. Thanks for reminding me about that one. That really should be released. For those interested Fandango highlighted the issue that Tag uses ";" as a delimiter for tag values; however EAC log files often contain ";". I have therefore changed the delimiter to "<#>" to stop confusion. Does anyone actually use this feature anyway?

I'm glad you have found a solution. FYI, you can easily export the CUESHEET tag using Tag.exe (>= 2.0.45):

CODE
--tocue <scheme>  : output cuesheet tag to file, name generated from <scheme>
--tocuen <name>   : output cuesheet tag to file <name>
--tocuea          : output cuesheet tag to file, name generated from source

However, there is no similar way to export EACLOG. One general solution would be to provide a switch like --export <tag>, e.g.: TAG.EXE --export EACLOG myfile.wv. This could write only that tag to STDOUT which could then be redirected to a text file, e.g.: TAG.EXE --export EACLOG myfile.wv > log.txt. Dunno.
Synthetic Soul
In fact, I've just done it, although I've used the far more confusing switch --tostdoutn, e.g.:

TAG.EXE --tostdoutn EACLOG myfile.wv>log.txt

Or:

CODE
@ECHO OFF
SET tmp="%TEMP%\tmp.txt"
FOR /R %%G in (*.wv) DO CALL :GetTags "%%G"
DEL %tmp%
GOTO:EOF
:GetTags
    TAG.EXE --tostdoutn EACLOG --hideinfo --hidetags --hidenames %1>%tmp%
    CALL :RenameTemp %tmp% "%~dpn1.log"
    TAG.EXE --tostdoutn CUESHEET --hideinfo --hidetags --hidenames %1>%tmp%
    CALL :RenameTemp %tmp% "%~dpn1.cue"
GOTO:EOF
:RenameTemp
    IF %~z1 NEQ 0 MOVE %1 %2
GOTO:EOF


Download 2.0.46b2 if you feel like playing.
Fandango
Oh, that's fantastic! Thanks a million. biggrin.gif
Synthetic Soul
Does that mean you've tried it?

Well, better late than never I guess. smile.gif It seemed like it could be useful, so I thought I'd give it a go anyway.

The only thing I don't really like is that it is really only useful when dealing with one file. The benefit of --tocue/a/n is that it will work even if you do TAG --recursive --tocuea *.wv. That said, this technique allows you to deal with the output pretty much as you like (redirect to file; pass to another app; etc.).
Synthetic Soul
Please Note:

I created 2.0.46b2 on XP at work, and it worked fine. I tried it here at home on Win 2K and it crashed.

I have fixed the bug and re-uploaded. The zip file is the same, but you will notice when running that the fixed version is labelled 2.0.46b2a.
Martin H
Thank you so much Synthetic Soul for adding this switch also, it's very much appreciated smile.gif It's really nice to be able to extract embedded cuesheets and now also embedded EAC log files with the use of batch files, instead of having to do it manually through copy/paste in fb2k. Again, thank you very much for your continued efforts of making TAG.EXE even better than it allready was.

CU - Martin.
Synthetic Soul
Thanks Martin H, it's good to know that it will be useful to some people. smile.gif

I thought of another use this morning: extracting the value of core tags, like Artist and Album, for use elsewhere in a batch file, e.g.:

CODE
@ECHO OFF

SET file=myfile.mp3

CALL :GetTag ARTIST %file%
CALL :GetTag ALBUM %file%
CALL :GetTag TITLE %file%
CALL :GetTag TRACK %file%

ECHO %ARTIST%
ECHO %ALBUM%
ECHO %TITLE%
ECHO %TRACK%

PAUSE

GOTO:EOF

:GetTag
    TAG.EXE --tostdoutn %1 --hideinfo --hidetags --hidenames %2>"%TEMP%\tmp.txt"
    SET /P %1=<"%TEMP%\tmp.txt"
    DEL "%TEMP%\tmp.txt"
GOTO:EOF

Using this technique you can easily create a batch file variable, with the same name as the tag, set to the content of the tag. smile.gif

Could be useful...
Fandango
QUOTE(Synthetic Soul @ Jun 7 2006, 17:36) *

Does that mean you've tried it?


Yes, I did. And both batch and Tag worked, no crash. smile.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.