--- /dev/null
+#!/usr/bin/python
+
+#
+# lossy_mirror.py
+#
+# Given a path to a folder of flac files, create a folder full of mp3 files
+# based on them and named similarly.
+#
+# Colin McCabe
+#
+
+import sys, getopt, os
+
+## Functions
+def my_system(cmd):
+ print cmd
+ ret = os.system(cmd)
+ if ret != 0:
+ print "command " + cmd + " failed with error code " + str(ret)
+ sys.exit(1)
+
+def quote(string):
+ return "\"" + string + "\""
+
+## Parse options
+try:
+ optlist, list = getopt.getopt(sys.argv[1:], ':hi:')
+except getopt.GetoptError:
+ print "autoftp [-v][-p][-h]"
+ sys.exit(1)
+
+input_folder = ""
+for opt in optlist:
+ print opt
+ if opt[0] == '-h':
+ Usage()
+ if opt[0] == '-i':
+ input_folder = opt[1]
+
+## Verify options
+if input_folder == "":
+ print 'You must give an input folder with -i'
+ sys.exit(1)
+
+input_folder = input_folder.rstrip('/')
+
+if not input_folder.endswith(' [LL]'):
+ print "Input folder \"" + input_folder + "\" doesnt end with \"[LL]\""
+ sys.exit(1)
+
+output_folder = input_folder[0:-5]
+abs_input_folder = os.path.abspath(input_folder)
+
+## Create new directory
+os.mkdir(output_folder)
+os.chdir(output_folder)
+
+for file in os.listdir(abs_input_folder):
+ if file.endswith('.flac'):
+ infile = abs_input_folder + "/" + file
+ wavfile = "./" + file + ".wav"
+ r = wavfile.rfind('.flac.wav')
+ mp3file = wavfile[0:r] + ".mp3"
+ my_system("flac -c -d " + quote(infile) + " > " + quote(wavfile))
+ my_system("lame -q 1 -b 192 " + quote(wavfile) + " " + quote(mp3file))
+
+for file in os.listdir("."):
+ if file.endswith('.wav'):
+ os.unlink(file)
+
+print "DONE"
+sys.exit(0)