6 # Given a path to a folder of flac files, create a folder full of mp3 files
7 # based on them and named similarly.
12 import sys, getopt, os
19 print "command " + cmd + " failed with error code " + str(ret)
23 return "\"" + string + "\""
27 optlist, list = getopt.getopt(sys.argv[1:], ':hi:')
28 except getopt.GetoptError:
29 print "autoftp [-v][-p][-h]"
41 if input_folder == "":
42 print 'You must give an input folder with -i'
45 input_folder = input_folder.rstrip('/')
47 if not input_folder.endswith(' [LL]'):
48 print "Input folder \"" + input_folder + "\" doesnt end with \"[LL]\""
51 output_folder = input_folder[0:-5]
52 abs_input_folder = os.path.abspath(input_folder)
54 ## Create new directory
55 os.mkdir(output_folder)
56 os.chdir(output_folder)
58 for file in os.listdir(abs_input_folder):
59 if file.endswith('.flac'):
60 infile = abs_input_folder + "/" + file
61 wavfile = "./" + file + ".wav"
62 r = wavfile.rfind('.flac.wav')
63 mp3file = wavfile[0:r] + ".mp3"
64 my_system("flac -c -d " + quote(infile) + " > " + quote(wavfile))
65 my_system("lame -q 1 -b 192 " + quote(wavfile) + " " + quote(mp3file))
67 for file in os.listdir("."):
68 if file.endswith('.wav'):