Help - Search - Members - Calendar
Full Version: FLAC, Metaflac and wildcards
Hydrogenaudio Forums > Lossless Audio Compression > FLAC
/\/ephaestous
I know that for some reason wildcards don't work in Flac since (I think) 1.0.1, Metaflac also doesn't support wildcards.

CODE

metaflac --add-replay-gain *.flac
*.flac: ERROR: reading metadata, status = "FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE"


So I've tried to use some DOS scripting (The good ol' dayz) to make up for that and I ended up with something like:

CODE

FOR /r %I IN (*.flac) DO metaflac --add-replay-gain "%~fI"


and in most cases it works, but on many files it keeps adding replay gain over and over. IE:

CODE

D:\>FOR /r %I IN (*.flac) DO metaflac --add-replay-gain "%~fI"
D:\>metaflac --add-replay-gain "D:\90's\Agra\Rebirth.flac"
D:\>metaflac --add-replay-gain "D:\90's\Agra\Rebirth.flac"
D:\>metaflac --add-replay-gain "D:\90's\Agra\Rebirth.flac"
D:\>metaflac --add-replay-gain "D:\90's\Agra\Rebirth.flac"
D:\>metaflac --add-replay-gain "D:\90's\Agra\Rebirth.flac"


It doesn't happen if I change 'add-replay-gain' with 'list' so I think it has got something to do with the dashes in the command line options.

Does anyone have any idea what causes this?
Will there be support for wildcards in the upcoming flac windows binaries?

BTW my PC uses Windows XP (AKA Fisher-Price OS).

Thx

PS. Sorry for my bad english, I haven't practiced in ages... sad.gif
Amadablam
I get the same problem in Windows, but not in Linux. metaflac.exe seems to deal with individual files just fine, but when I use wildcards like * or *.flac with --add-replay-gain or --remove-vc-field, I get the same error that you reported.
Annuka
The reason * works under UNIX is caused by the shell - i.e. bash - not flac or metaflac.
/\/ephaestous
It's true, BASH expands the wildcards itself while cmd leaves that to the app
/\/ephaestous
okay I've found the solution now.. it's not pretty but it works:
I make a batch (.cmd) like:

CODE

@echo off
dir *.flac /b /a:-d /o:n /s > %temp%\flac.list
@echo Adding 32Kb of padding.
for /f "tokens=1 delims=" %%a in ( %temp%\flac.list ) do metaflac --add-padding=32768 "%%a"
for /f "tokens=1 delims=" %%a in ( %temp%\flac.list ) do metaflac --sort-padding "%%a"
del %temp%\flac.list


and it works, it adds 32kB of padding to every flac file in the folder and subfolders of the directory I started the cmd in (it also sorts the padding in case it allready had a pading block). It should work with any command but only on NT4/2K/XP because 9X/Me lacks the /F extension for the FOR command
nhawkGT
This is an old thread, but I found myself in the same situation today. So here's my solution for Windows XP, which should work correctly for album gain calculations.

CODE
@echo off
rem filename is metaflac2.bat
rem
rem this batch file requires Command Extensions, so you need to
rem run it like this...
rem
rem CMD.EXE /V:ON /C metaflac2.bat *.flac otherfile.flac etc.flac
rem
set METAFLAC_FILES=
for %%a in (%*) do (
 set METAFLAC_FILES=!METAFLAC_FILES! "%%a"
)
metaflac.exe --add-replay-gain --add-seekpoint=1s %METAFLAC_FILES%
set METAFLAC_FILES=

It requires delayed environment variable expansion, which is part of Command Extensions in Windows XP (and I believe Windows 2000, but not sure). Same idea can be applied to any other program that needs wildcards expanded, like flac.exe. Hope this helps others in the same situation.
scottws
I think it would just be easier if FLAC could handle the wildcard in Windows.
jcoalson
Wildcard expansion belongs in the shell.

But I did just find out about this workaround which I will try out:

http://mail.python.org/pipermail/python-de...une/000400.html
http://mail.python.org/pipermail/python-de...une/000401.html

Josh
scottws
QUOTE(jcoalson @ Mar 15 2004, 03:52 PM)
Wildcard expansion belongs in the shell.

That first link you posted disagrees with you.

Anyway it's irrelevant because it's not there in cmd.exe and I don't think any complaining is going to get Microsoft to change this (did old DOS handle wildcard expansion like bash does in Linux?), so I hope that you can somehow include it in flac.exe, flac-dec.exe, and metaflac.exe in the future.
jcoalson
QUOTE(scottws @ Mar 15 2004, 05:35 PM)
QUOTE(jcoalson @ Mar 15 2004, 03:52 PM)
Wildcard expansion belongs in the shell.

That first link you posted disagrees with you.

I know. the interesting part was that you can get globbing just by linking with setargv.obj.

QUOTE(scottws @ Mar 15 2004, 05:35 PM)
Anyway it's irrelevant because it's not there in cmd.exe and I don't think any complaining is going to get Microsoft to change this (did old DOS handle wildcard expansion like bash does in Linux?), so I hope that you can somehow include it in flac.exe, flac-dec.exe, and metaflac.exe in the future.

apparently it doesn't have to be in cmd.exe, the linked-in code munges argv for you before calling main().

Josh
WaldoMonster
The workaround example from nhawkGT works with average length albums.
But doesn’t work for album boxes on my Windows 2000 computer.
The command prompt (cmd.exe) has a string limitation, more for NT4 and Windows 2000 than for Windows XP and newer.
Command prompt (Cmd. exe) command-line string limitation

This is also a reason to add FLAC wildcard support on the Windows console version.
jth
Unix shells have limits as well, but that isn't a compelling argument to have an application do wildcard expansion.

Tools like xargs work around the problem rather nicely.

--jth
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.