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: Batch convert FLAC to MP3 with copying of folder structure. (Read 48639 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Batch convert FLAC to MP3 with copying of folder structure.

HELLo.
I want to convert my FLAC  an APE collection to MP3 with highest quality, because FLAC is too big for my mp3 player.
I know how to convert between formats (but if somebody give me correct parameters for mp3 settings I will be thankfull)
Problem is that I want to convert it in batch proccess.
Now I have my FLAC collection in directory "D:\Music\Flac\...." and I want to convert it automaticly to the folder d:\Music\MP3, with keeping of everything, like tags,album art in tag folder and subfolder structure and files.
Thanks a lot for answer

Batch convert FLAC to MP3 with copying of folder structure.

Reply #1
Copy the Flac folder to the MP3 folder, then use foobar to convert the contents of the MP3 folder (which currently contains FLACs) to MP3s and after that delete all flac files (for example from within foobar).

Batch convert FLAC to MP3 with copying of folder structure.

Reply #2

Use:
Code: [Select]
$replace(%path%,\FLAC\,\MP3\)\%filename%

In the Name Format box of the Converter.
elevatorladylevitateme

Batch convert FLAC to MP3 with copying of folder structure.

Reply #3
Copy the Flac folder to the MP3 folder, then use foobar to convert the contents of the MP3 folder (which currently contains FLACs) to MP3s and after that delete all flac files (for example from within foobar).

Thanks , it is also solution (maybe best), but I dont have enough storage capacity for it.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #4
Use:
Code: [Select]
$replace(%path%,\FLAC\,\MP3\)\%filename%

In the Name Format box of the Converter.


Thanks a lot, It seems interesting, but results are strange.
For instance when I converting from directory d:\Hudba\__FLAC\Teatro Fatal - Divadlo Frizúr\
result is d:\Hudba\__FLAC\Teatro Fatal - Divadlo Frizúr\D-\Hudba\__MP3\Teatro Fatal - Divadlo Frizúr\01 Divadlo frizúr.flac\
that mean that it create in orginal directory subdirectory D-\Hudba\__MP3\Teatro Fatal - Divadlo Frizúr
than in this subdirectory next subdirectory with original name of song \01 Divadlo frizúr.flac\ and in this subdirectory is song stored

I use your command (modified to __FLAC and __MP3)  in field  called  "Name format"
And output folder seting "Same as source file"

But biggest problem is that it doesn´t keep album art in tag, or dosn´t copy abum art file from source directory.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #5
Thanks a lot, It seems interesting, but results are strange.
For instance...
Yeah, for Output Path you'll need to select "Specify folder" and leave it blank. My guess is you selected "Source Track Folder".

But biggest problem is that it doesn´t keep album art in tag, or dosn´t copy abum art file from source directory.

It's a new file, so it never had artwork; there is nothing to "keep". But yes, the Converter doesn't transfer artwork from source tags to the new file's tags. No part of fb2k does artwork embedding, the Converter included.

I believe dbPowerAmp does, if you need a program to do that. You can also embed art in the files post-conversion, using mp3tag.
elevatorladylevitateme

Batch convert FLAC to MP3 with copying of folder structure.

Reply #6
I believe dbPowerAmp does, if you need a program to do that. You can also embed art in the files post-conversion, using mp3tag.


Yes, dbpa will do it all including transferring the album art, embedded or in subdirectory as file, or both, as well as allowing you to have a dynamic naming string so that the new mp3 directory mirrors the structure of the old FLAC directory with the exception of the first level (i.e., flac vs mp3)

Batch convert FLAC to MP3 with copying of folder structure.

Reply #7
Thanks people,
It seems that dbPowerAmp is good solution.
So now few our of converting waiting for me.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #8
Thanks a lot, It seems interesting, but results are strange.
For instance...
Yeah, for Output Path you'll need to select "Specify folder" and leave it blank. My guess is you selected "Source Track Folder".

But biggest problem is that it doesn´t keep album art in tag, or dosn´t copy abum art file from source directory.

It's a new file, so it never had artwork; there is nothing to "keep". But yes, the Converter doesn't transfer artwork from source tags to the new file's tags. No part of fb2k does artwork embedding, the Converter included.

I believe dbPowerAmp does, if you need a program to do that. You can also embed art in the files post-conversion, using mp3tag.


I'm having the same trouble.  I have a large directory of albums that I want to convert to mp3 and keep a similar directory structure in the new folder, so I decided to just try your method out on one track to see if I could get it to work.

I'm trying to convert this:
C:\Users\Mike\Music\Doors\flac\01 Doors - Doors (DCC Gold)\The Doors - The Doors (DCC Gold) - 01 - Break On Through (To The Other Side).flac

To this:
C:\Users\Mike\Music\Doors\mp3\01 Doors - Doors (DCC Gold)\The Doors - The Doors (DCC Gold) - 01 - Break On Through (To The Other Side).mp3

And in the preview window, Foobar is telling me it will do this:
C-\Users\Mike\Music\Doors\flac\01 Doors - Doors (DCC Gold)\The Doors - The Doors (DCC Gold) - 01 - Break On Through (To The Other Side).flac\The Doors - The Doors (DCC Gold) - 01 - Break On Through (To The Other Side).mp3

I don't know why it's putting a dash after the C, and why it thinks it should make a subdirectory of a file.

I selected "specify folder" and left it blank, as you said.  And when I click OK, to make the conversion, it brings up a window asking me to choose a destination folder.

What am I doing wrong here?

Batch convert FLAC to MP3 with copying of folder structure.

Reply #9
because you put that pattern in name format and colon [:] is not valid character

you should select root folder in "Output path" setting and use some common sense in name pattern (check foobar help file)

Batch convert FLAC to MP3 with copying of folder structure.

Reply #10
because you put that pattern in name format and colon [:] is not valid character

you should select root folder in "Output path" setting and use some common sense in name pattern (check foobar help file)

But I didn't put that pattern in the name format, though.  What I put was:
Code: [Select]
$replace(%path%,\FLAC\,\MP3\)\%filename%

And Foobar is trying to create a directory off a file (Which is impossible), and putting in a dash after the C.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #11
Well sure you did, what do you think %path% evaluates to? You need strip the "base" directory and not add another %filename%:
Code: [Select]
$replace(%path%,c:\Users\Mike\Music,,\flac\,\mp3\)
Change the "c:\users\.." to where you have pointed the converter. The converter dialogue has a preview of the output paths you can always check before you start a conversion, although it won't popup if you choose a preset from the submenu.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #12
Hi,

Sorry to resurrect an old thread.  I've had the same problem with the output from F2k and, while using %path% is a nice option, I would prefer to be able to copy artwork too.  Currently, I use F2k to convert the FLAC files into mp3 in the source folders, and then use the following python script to move the mp3s into a new folder while copying the artwork and maintaining the directory structure.  I thought I'd share the code as, until F2k is updated, this will be an issue.

Notes on code:
1) Code is a hack, comes without warranty
2) Takes two folders - input folder with flac/mp3/artwork, empty output folder for mp3
3) Input folder must not be a subfolder of output folder or vice versa
4) Overwrites files in target directory without warning  (wont delete any files, however)
5) Works on windows, could be modded for linux

Code: [Select]
print "-----------------------------------------------"
print "Application to relocate mp3 files whilst "
print "preserving directory structure and album art"
print "DL 2012"
print "v. 0.1"
print "-----------------------------------------------"

import os, subprocess
import tkFileDialog
from Tkinter import *
from tkMessageBox import askokcancel

# moveit: file f relocates from src to dest
def moveit( f , sorc , dest):
    fullPath = sorc + "\\" + f
    subprocess.Popen("move" + " \"" + fullPath + "\" " + " \"" + dest + "\" ",shell=True)
    return

# copyit: file f duplicates in dest folder
def copyit( f , sorc , dest):
    fullPath = sorc + "\\" + f
    subprocess.Popen("copy" + " \"" + fullPath + "\" " + " \"" + dest + "\" ",shell=True)
    return

# parseDirs: reproduces directory structure, copys/moves files
def parseDirs(srcMain , dstMain):
    src = srcMain
    dst = dstMain

    reparseDirs = [] # directories to reparse
    reparseDirs.append('')

    # outer loop : moves between directories
    while len(reparseDirs)>0:
        subfolder = reparseDirs.pop()
        print('\rreparseDirs:' + src + "\\" + subfolder)
        listOfFiles = os.listdir(src + "\\" + subfolder)
       
        # inner loop : moves files, creates directories
        for f in listOfFiles:
            temp = f
            temp=temp.lower()

            #verify file longer than 4 chars (e.g. at least x.xx)
            if len(temp)>3:
                ext = temp[len(temp)-4:len(temp)]
            else:
                ext = 'x.xx' # dummy output
           
            # identify file type
            if os.path.isdir(src + "\\" + subfolder + "\\" + f):
            # duplicate folder structure
                print('creating folder: ' + f)
                try:
                    os.mkdir(dst + "\\" + subfolder + "\\" + f)
                except OSError:
                    print 'folder already exists'
                reparseDirs.append(subfolder + "\\" + f) # search source dir for files
            elif ('flac' in ext)|('ape' in ext)|('m4a' in ext)|('alac' in ext):
            #ignore lossless
                print ('ignoring lossless file: ' + f)
            elif 'cue' in ext:
            #ignore cue
                print ('ignoring cue file: ' + f)
            elif 'mp3' in ext:
            #relocate mp3
                print ('moving mp3 in file: ' + f)
                moveit(f , src + "\\" + subfolder, dst + "\\" + subfolder)
            else:
            #copy other file types
                print ('copying file: ' + f)
                copyit(f , src + "\\" + subfolder, dst  + "\\" + subfolder)

###########  Begin GUI Block
class openDialog(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, parent)
        self.parent = parent # create a reference to the Tk() instance
        self.createWidgets()
        self.launchApp()

    def createWidgets(self):
        self.textDirIn = StringVar()
        self.textDirOut = StringVar()
       
        self.DirIn = Entry(self, width=70, textvariable=self.textDirIn)
        self.DirIn.pack()

        self.DirOut = Entry(self, width=70, textvariable=self.textDirOut)
        self.DirOut.pack()

        self.pack()

    def getDir(self):
        self.dirin=tkFileDialog.askdirectory()
        return self.dirin
       
    def launchApp(self):
        inputDir = self.getDir()
        self.textDirIn.set(inputDir)
        outputDir = self.getDir()
        self.textDirOut.set(outputDir)

        if askokcancel(title="Continue?", message="Continue using these folders?"):
            print 'Continue...'
            parseDirs(inputDir,outputDir)
            self.textDirIn.set('complete!')
            self.textDirOut.set('close window to finish')
            print 'complete: close window to finish'
        else:
            print 'Operation cancelled'
            self.textDirIn.set('cancelled')
            self.textDirOut.set('cancelled')
###########  End GUI Block

#### MAIN ####
if __name__ == "__main__":
    root=Tk()
    openDialog(root)
    root.mainloop()

Batch convert FLAC to MP3 with copying of folder structure.

Reply #13
Just in case it helps others, this is what I use when converting FLAC to MP3.
I am using an old version of Foobar (v.1.1.7) so you may need to tweak this slightly.
My artwork is not embedded - I keep it as separate files (usually "cover.jpg") inside the relevant directories.

Suppose FLACs are in C:\Users\Popeye\Music\Flacs

1) Create a suitable folder for the MP3 files e.g. C:\Users\Popeye\Music\MP3s
2) Load up your FLAC directory into Foobar and make sure all the files are highlighted
3) Right click on the files and select "Convert / ..."
4) Output Format Settings - Set the output type to MP3 and choose your quality setting
5) Destination Settings - Click on "Specify folder" and browse to whatever folder you created in step 1
6) Destination Settings - Use the following name formatting for "Convert each track to an individual file":

$replace(%path%,C:\Users\Popeye\Music\Flacs,,.flac,)

7) Other Settings - Type the following in "Copy other files to the destination folder" to copy all artwork across:

*.jpg;*.gif;*.png

8) Convert!

What this does is to replace "C:\Users\Popeye\Music\Flacs" with "", and also the ".flac" with "".
i.e. It strips down the path to just the subdirectory within your FLACs folder, together with the filename minus the .flac extension.
The converter then appends this to your chosen MP3 directory, and automatically adds the MP3 extension.

My understanding of $replace is that it works like this: $replace(A,B1,C1,B2,C2,B3,C3,...,Bn,Cn)
It looks inside string A, replacing Bi with Ci for i=1,2,3,...,n.

Bluto

Batch convert FLAC to MP3 with copying of folder structure.

Reply #14
hey all,

thanks for this thread. really helped me out by converting my entire flac library to mp3 while keeping the same folder structure.

for anyone else who wants to know

im using foobar v1.1.10
select files, right click
specify the output folder
select "generate multi-tracks"
paste this $replace( %directoryname%\ %filename%,\FLAC\,\MP3\)
and it will do it perfectly.

test with a few files first to make sure, but its working great for me.
good luck.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #15
my bad.
the post above doesnt recreate all subfolders.

this one does.

$replace( $replace(%path%,.flac,),\FLAC\,\MP3\)

just change .flac if you have other formats.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #16
You might also want to have a look at flac2mp3.py. As well as doing the conversion, it has lots of useful features, like using an MD5 checksum to work out which file(s) haven't changed since the last conversion and only converting those that have, and allowing you to only update the tags between your lossless and lossy library.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #17
my bad.
the post above doesnt recreate all subfolders.

this one does.

$replace( $replace(%path%,.flac,),\FLAC\,\MP3\)

just change .flac if you have other formats.


This doesn't seem to work for me - I get the same problem the original poster had.

Foobar won't preserve the colon in C: if it appears in the full path, changing it to C- instead.
The only way round this as far as I can tell is to specify a target folder, and strip the initial part
of the path completely as in my post #14 above.

Bluto

Batch convert FLAC to MP3 with copying of folder structure.

Reply #18
Bluto, you rock.  Using your directions in post #14, I was able to eliminate a very tedious step from my conversion process.  I specified my Mp3 output folder under "Output path", and then spliced my root FLAC source folder into your code, and Foobar now automatically creates the entire subdirectory structure in my specified MP3 destination.  For the others, my code now looks like this:
Code: [Select]
$replace(%path%,C:\Temp\MUSIC RIP,,.flac,)
To Bluto, I get the same result whether the code is pasted under individual or multi-track output files, so I've left it at individual for now.  To everyone else, if you try transcoding a FLAC which isn't in the source folder specified in the code, it's not going to work properly.  Now, if we could find a way to have Foobar preserve the album art during the transcode, I'd be one happy camper.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #19
Glad it worked for you!

I don't think Foobar can copy across embedded artwork yet; I seem to recall this being raised before in the forum as something which wasn't possible. Personally, I don't like the thought of cluttering up music files with graphics data. Having a single "cover.jpg" file in each directory works fine for me, and is easy to change if necessary without altering the music files themselves.

Regarding the Foobar options, I'm not at all sure what "Generate Multi-track files" means, given that there is already an option for "Merge all tracks into one output file".

Bluto

Batch convert FLAC to MP3 with copying of folder structure.

Reply #20
Now, if we could find a way to have Foobar preserve the album art during the transcode, I'd be one happy camper.
I don't think Foobar can copy across embedded artwork yet; I seem to recall this being raised before in the forum as something which wasn't possible.
bluto is correct. Whether this will be addressed remains to be seen.

Batch convert FLAC to MP3 with copying of folder structure.

Reply #21
hey all,

thanks for this thread. really helped me out by converting my entire flac library to mp3 while keeping the same folder structure.

for anyone else who wants to know

im using foobar v1.1.10
select files, right click
specify the output folder
select "generate multi-tracks"
paste this $replace( %directoryname%\ %filename%,\FLAC\,\MP3\)
and it will do it perfectly.

test with a few files first to make sure, but its working great for me.
good luck.



my bad.
the post above doesnt recreate all subfolders.

this one does.

$replace( $replace(%path%,.flac,),\FLAC\,\MP3\)

just change .flac if you have other formats.


ryangoan you are a life saver. Thank you!

Batch convert FLAC to MP3 with copying of folder structure.

Reply #22
Hi

thanks for a lot of info but i still strugle

i will convert flac to mp3 (div players)



flac is like this by artist\album (nas server)
\\modesty\Modesty\media\Min musikk\FLAC\Pop og rock\Adele\Adele 19\(all songs to album 19.flac)
\\modesty\Modesty\media\Min musikk\FLAC\Pop og rock\Adele\Adele 21\(all songs to album 21.flac)


i like to have output cat like this

\\modesty\Modesty\media\mp3 convert\Adele\Adele 19\(all songs by songs from album 19.mp3)
\\modesty\Modesty\media\mp3 convert\Adele\Adele 21\(all songs by songs from album 21.mp3)


i have tried with quite success with a double replace but i cant get i right, i get extra catalogs under my mp3 convert cat

$replace( $replace(%path%,\modesty\modesty\media\Min musikk,),\FLAC\,\\\\)


i get this
m:\mp3 convert\_\Pop og rock\Adele\Adele - 19\songs.mp3

I hope some of ou can help me out...

Thanks

Batch convert FLAC to MP3 with copying of folder structure.

Reply #23
Thanks everyone for all of the info.  I had a similar issue to the OP.  I played around with functions like replace and substr and I am amazed at the flexibility...but it was overkill for what I was wanting to do.

All of my FLAC files were in C:\media\audio\lossless\CD\<artist>\<album>\<filename>.flac

The easiest way, that I found, to get everything automatically copied to
C:\media\audio\lossy\CD\<artist>\<album>\<filename>.mp3

was to configure the converter Destination like this:
Output path: C:\media\audio\lossy\CD
Name format: %artist%\%album%\%filename%

and configure the converter Other like this:
[checked] Transfer metadata (tags)
[checked] Transfer attached pictures
Copy other files to the destination folder: *.jpg (to copy album art, if stored externally)

Example input: C:\media\audio\lossless\CD\Nine Inch Nails\Fixed\02 Wish [Remixed by J.G. Thirlwell].flac
Resulting output: C:\media\audio\lossy\CD\Nine Inch Nails\Fixed\02 Wish [Remixed by J.G. Thirlwell].mp3

Folders were automatically created.

Hope this helps!

Batch convert FLAC to MP3 with copying of folder structure.

Reply #24
Quote
flac is like this by artist\album (nas server)
\\modesty\Modesty\media\Min musikk\FLAC\Pop og rock\Adele\Adele 19\(all songs to album 19.flac)
\\modesty\Modesty\media\Min musikk\FLAC\Pop og rock\Adele\Adele 21\(all songs to album 21.flac)


i like to have output cat like this

\\modesty\Modesty\media\mp3 convert\Adele\Adele 19\(all songs by songs from album 19.mp3)
\\modesty\Modesty\media\mp3 convert\Adele\Adele 21\(all songs by songs from album 21.mp3)


Here is a simple solution, using the foobar formatting function $directory(x,n), which extracts the nth directory from below of the pathname x.

For the example, in the destination dialog, set the output folder to : \\modesty\Modesty\media\mp3 convert

In the name format, use the following string:

$directory(%path%,2)\$directory(%path%,1)\%filename%

which will let you keep the two directories over the filename: \Adele\Adele 21\

In the preview area in the lower part of the dialog window you can see the final result of the naming scheme, before starting the batch conversion.

Best regards