Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Logging errors when FLAC is run from a batch script (Read 2551 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Logging errors when FLAC is run from a batch script

I am a latecomer to FLAC.

I wrote a one-line batch script to encode all WAVs in a directory to FLAC:
Code: [Select]
FOR /R %%I IN (*.wav) DO "C:\Program Files\flac-1.2.1-win\bin\flac.exe" "%%I"


If I run this script, how can I tell if the encoding process completed without any errors? If FLAC produces an error message or aborts or something, I may not see it, since the window auto-closes after the script finishes running.

I was wondering if there might be a way to output errors to a log file.
I had a look through the FLAC documentation and it seems the --verify command line option might be needed, but still, if an error is encountered, what would happen in the context of my batch script?

Thanks for your help.

Logging errors when FLAC is run from a batch script

Reply #1
In batch you can do redirection of stdout and stderr:

stdout:
command.exe > output.txt
or the equivalent:
command.exe 1> output.txt

stderr:
command.exe 2> errors.txt

both:
command.exe > all.txt 2>&1


Use >> to append to the file, else every command call will overwrite the file.

You could also do command1 || command2, which means command2 will only be run if command1 fails.
Example: flac "%%I" || echo "%%I" >> errors.txt
"I hear it when I see it."

 

Logging errors when FLAC is run from a batch script

Reply #2
That's great. Thanks!