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: FLAC, Metaflac and wildcards (Read 7422 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FLAC, Metaflac and wildcards

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: [Select]
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: [Select]
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: [Select]
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... 
"You have the right to remain silent. Anything you say will be misquoted, then used against you."

FLAC, Metaflac and wildcards

Reply #1
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.

FLAC, Metaflac and wildcards

Reply #2
The reason * works under UNIX is caused by the shell - i.e. bash - not flac or metaflac.

FLAC, Metaflac and wildcards

Reply #3
It's true, BASH expands the wildcards itself while cmd leaves that to the app
"You have the right to remain silent. Anything you say will be misquoted, then used against you."

FLAC, Metaflac and wildcards

Reply #4
okay I've found the solution now.. it's not pretty but it works:
I make a batch (.cmd) like:

Code: [Select]
@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
"You have the right to remain silent. Anything you say will be misquoted, then used against you."

FLAC, Metaflac and wildcards

Reply #5
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: [Select]
@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.

FLAC, Metaflac and wildcards

Reply #6
I think it would just be easier if FLAC could handle the wildcard in Windows.


FLAC, Metaflac and wildcards

Reply #8
Quote
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.

FLAC, Metaflac and wildcards

Reply #9
Quote
Quote
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
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

FLAC, Metaflac and wildcards

Reply #10
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.

FLAC, Metaflac and wildcards

Reply #11
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