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
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()