Help - Search - Members - Calendar
Full Version: command line to decode FLACs into new directory?
Hydrogenaudio Forums > Lossless Audio Compression > FLAC
AnEnigma66
Is there a command line that will allow me to decode a group of FLAC files from a specific directory structure into a different partition or drive and recreate the directory structure they're currently in without me manually specifying that directory for each artist? In other words, if they're currently archived like so:

G:\Music\Artists\Albums\FLACs

Is there a command line that will decode them to:

F:\Music\Artists\Albums\WAVs ???

Duble0Syx
Not sure if your on linux or windows. You could probably make script on linux to do it. On windows the best way I can think of would be to use Foobar2000 to decode them, as you do exactly what you want.

EDIT: dumb ass me, the drive letters should have given away that your on windows. smile.gif
Synthetic Soul
Save the following as flac-decode.bat and double click to run:

CODE
FOR /R "G:\Music\Artists\Albums\FLACs" %%G IN (*.flac) DO FLAC.EXE -d "%%G" -o "F:%%~pnG.wav"

This will decode any FLAC in "G:\Music\Artists\Albums\FLACs" to "F:\Music\Artists\Albums\FLACs", maintaining all subdirectories. You will just need to rename "F:\Music\Artists\Albums\FLACs" to "F:\Music\Artists\Albums\WAVs" afterward, if you really want to.

Or, for the same effect, run:

CODE
FOR /R "G:\Music\Artists\Albums\FLACs" %G IN (*.flac) DO FLAC.EXE -d "%G" -o "F:%~pnG.wav"

...direct from the command line.

Or use foobar.
AnEnigma66
I'm either not quite understanding the instructions, or I was unclear in my initial post. My files are IN a specific directory structure, but "G:\Music\Artists\Albums\FLACs" isn't it. That's just the general description of what the structure looks like.

G:\FLACs\Artist 1\Album1\
G:\FLACs\Artist 1\Album2\
G:\FLACs\Artist 2\Album1\
G:\FLACs\Artist 3\Album1\
G:\FLACs\Artist 3\Album2\
G:\FLACs\Artist 3\Album3\

... and so on.

I've since downloaded Foobar, but I don't understand the syntax. What I want to do is drag a few folders of artists into Foobar (or any front end), and have them decoded to WAVs on my F: drive, and have the directory structure maintained. Sorry if I'm not being clear on this.
Duble0Syx
QUOTE(AnEnigma66 @ Sep 27 2005, 01:43 PM)
What I want to do is drag a few folders of artists into Foobar (or any front end), and have them decoded to WAVs on my F: drive, and have the directory structure maintained.
*


In foobar go to Preferences > diskwriter
For output formatting it sounds like you'd want to enter something like this:
%artist%\%album%\%_filename%

Then just pick the main directory and choose WAV (fixed-point) as the ouptut.
Add your files to the playlist, highlight them, right click and hit convert. Make sure no processing options are on below of course. smile.gif That should do it.

EDIT: spelling.
kockroach
I'm using fb2k 0.8.3. In the settings for diskwriter, you want to have the output directory set, but do not check either option stating "Always ask...." and "Same as Source...."

You could set the Output directory simply as "F:"

Then, under "Output file name formatting:" use the following:

CODE
WAVs\$directory(%_path%,2)\$directory(%_path%)\%_filename%


Also, make sure to check "Create subdirectories". Also, you will want to choose the proper Output preset, in this case WAV.

That should work, as it is based on what I do for converting my FLAC files to MP3.

Edit: typos
Synthetic Soul
Sorry. Then you would use:

CODE
FOR /R "G:\FLACs" %%G IN (*.flac) DO FLAC.EXE -d "%%G" -o "F:%%~pnG.wav"


This will look in "G:\FLACs" and all subfolders for a FLAC file and convert it over to the F: drive.

If "G:\FLACs" isn't really to root of all your folders either then replace "G:\FLACs" with the folder that is the root.

CODE
G:\FLACs\Artist 1\Album1\  ->  F:\FLACs\Artist 1\Album1\
G:\FLACs\Artist 1\Album2\  ->  F:\FLACs\Artist 1\Album2\
G:\FLACs\Artist 2\Album1\  ->  F:\FLACs\Artist 2\Album1\
G:\FLACs\Artist 3\Album1\  ->  F:\FLACs\Artist 3\Album1\
G:\FLACs\Artist 3\Album2\  ->  F:\FLACs\Artist 3\Album2\
G:\FLACs\Artist 3\Album3\  ->  F:\FLACs\Artist 3\Album3\

This is just a down'n'dirty way of achieving what you want.

Using foobar is a more sophisticated method.
AnEnigma66
Thanks guys, I'll give those ideas a try.
M
QUOTE(kockroach @ Sep 27 2005, 05:13 PM)
I'm using fb2k 0.8.3.  In the settings for diskwriter, you want to have the output directory set, but do not check either option stating "Always ask...." and "Same as Source...."

You could set the Output directory simply as "F:"

Then, under "Output file name formatting:" use the following:

CODE
WAVs\$directory(%_path%,2)\$directory(%_path%)\%_filename%


Also, make sure to check "Create subdirectories". ...
*


Is there an equivalent "Create subdirectories" option in the 0.9 betas, or have I simply failed to find it? A quick test of the formatting string produced the expected files, but all were placed in the root directory selected.

- M.
Synthetic Soul
There is no such option with converter, subdirectories are always created.

I don't know how the string failed.

Did you test one file? If you test one file no subfolders will be created - the file will simply be created with the name specified in the dialogue, in the folder specified in the dialgue.

To bring the output file name string into play try to convert two or more files, by selecting "Convert > Convert to...".
M
QUOTE(Synthetic Soul @ Sep 30 2005, 05:55 AM)
There is no such option with converter, subdirectories are always created.

I don't know how the string failed.

Did you test one file?  If you test one file no subfolders will be created - the file will simply be created with the name specified in the dialogue, in the folder specified in the dialgue.

To bring the output file name string into play try to convert two or more files, by selecting "Convert > Convert to...".
*


I ran the test with four files (two in each of two directories, nested in the same relative path). Here is my structure:

CODE
I:
 Beatles - mono collection (EMI-Parlophone BM1)
   UK 45 Collection
     1962-10-05 single (Parlophone 45-R 4949)
       01 Love Me Do.flac
       02 PS I Love You.flac
     1963-01-11 single (Parlophone 45-R 4983)
       01 Please Please Me.flac
       02 Ask Me Why.flac

... but regardless of how I set the paths in the output string, I seem to get the resultant files dropped in the root of whatever directory I select from "Convert to..." (if used without the hard-coded directory prefix; if a hard-coded directory is specified, the files are all placed within it, but still without subdirectories).

- M.
Synthetic Soul
Actually, mine does too.

I'm sorry, I didn't test the string kockroach posted. I assumed it must work as he uses it. Never assume...

I've now tested and it does work in 0.8.3, just not in 0.9.

I don't think you can use $directory() in 0.9 in this situation. I tested the string as my copy command, and it works as expected.

"WAVs\$directory(%path%)\%filename%" does not work, but "WAVs\%filename%\%filename%" and "WAVs\%path%\%filename%" do.
kockroach
Sorry if things didn't work like it does for me. I did mention that I use 0.8.3, but I forgot to ask which version you were using. It wasn't mentioned in the thread title or first post....I assumed that since 0.9 is still being tested that you were using 0.8.3.

As Synthetic Soul mentioned, never assume... smile.gif

In 0.8.3 I tried using only %path%, but it wouldn't do multiple levels of folders. After testing a couple of different strings, I came up with the one I gave above.
M
QUOTE(Synthetic Soul @ Sep 30 2005, 07:44 AM)
Actually, mine does too.

I'm sorry, I didn't test the string kockroach posted.  I assumed it must work as he uses it.  Never assume...

I've now tested and it does work in 0.8.3, just not in 0.9.

I don't think you can use $directory() in 0.9 in this situation.  I tested the string as my copy command, and it works as expected.

"WAVs\$directory(%path%)\%filename%" does not work, but "WAVs\%filename%\%filename%" and "WAVs\%path%\%filename%" do.
*


The results are not quite what I was expecting! Ideally, the subdirectory structure would be replicated as a whole. Instead, each output file is placed in its own, uniquely named directory.

When I use "WAVs\%path%\%filename%" I get the following subdirectories created in "WAVs" (yes, these are directories even though they have the .flac extension; each contains the respective output .wav file):
CODE
I__Beatles - mono collection (EMI-Parlophone BM1)_UK 45 Collection_1962-10-05 single (Parlophone 45-R 4949)_01 Love Me Do.flac
I__Beatles - mono collection (EMI-Parlophone BM1)_UK 45 Collection_1962-10-05 single (Parlophone 45-R 4949)_02 PS I Love You.flac
I__Beatles - mono collection (EMI-Parlophone BM1)_UK 45 Collection_1963-01-11 single (Parlophone 45-R 4983)_01 Please Please Me.flac
I__Beatles - mono collection (EMI-Parlophone BM1)_UK 45 Collection_1963-01-11 single (Parlophone 45-R 4983)_02 Ask Me Why.flac

... and switching to "WAVs\%filename%\%filename%" yields a similar result, save that the subdirectory names are simply the same as the file names or the original .flac files.

Any thoughts?

- M.

Edit: Cleaned up post a bit.
Synthetic Soul
Sorry M - I wasn't posting those strings as alternatives, but merely to prove that it was the $directory() function that was causing the problems.

Sorry for the confusion.

As an actual resolve to the problem I would either use 0.8.3 for this task, or use my batch file approach.
M
QUOTE(Synthetic Soul @ Oct 1 2005, 03:30 AM)
Sorry M - I wasn't posting those strings as alternatives, but merely to prove that it was the $directory() function that was causing the problems.

Sorry for the confusion.

As an actual resolve to the problem I would either use 0.8.3 for this task, or use my batch file approach.
*


Ah... quite all right. I've got it working with batch files, although I had to manually create the directory structure in the destination; is there a simple way to instruct the system to create subdirectories as needed?

For most of my purposes I prefer batch files anyway... it was just frustrating not being able to figure out how/why foobar wasn't doing what had been described!

- M.
Synthetic Soul
Hmm. I assumed FLAC would create the directories if they didn't exist.

I guess you would use:

CODE
FOR /R "G:\FLACs" %%G IN (*.flac) DO MKDIR "F:%%~pG" && FLAC.EXE -d "%%G" -o "F:%%~pnG.wav"

... or in an expanded format:

CODE
FOR /R "G:\FLACs" %%G IN (*.flac) DO CALL :Decode "%%G"

GOTO:EOF

:Decode
IF NOT EXIST "F:%~p1" MKDIR "F:%~p1"
FLAC.EXE -d %1 -o "F:%~pn1.wav"
GOTO:EOF
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.