2011-10-29 13 views
0

すべてのflacファイルを作業ディレクトリのoggに変換したい:Python Flacファイルの一括変換

これは私がすでに持っているものです。私のFLACファイルを含むディレクトリに - -

for root, dirs, files in os.walk(args): 
     flacs = [f for f in files if f.endswith('.flac')] 
     oggs = [o for o in files if o.endswith('.ogg')] 

     for flacfiles in flacs: 
      id3 = ('id3v2', '-C', flacfiles) 
      cmd = ('oggenc', '-q7', flacfiles) 
      try: 
       subprocess.check_call(id3, cwd=root) 
       subprocess.check_call(cmd, cwd=root) 
      except subprocess.CalledProcessError: 
       print "subprocess.CalledProcessError: Command %s returned non-zero exit status 1" % cwd 

は今、私は私ができる方法を知りたい.cueと1 .flacがあるかどうかを確認し、それがdo_somethingケース()

+2

ある場合また、[GNU Make](http://www.gnu.org/s/make/)も検討してください。このようなタスクを解決するために特に開発されました。 [このMakefile](http://www.mat.univie.ac.at/~eno/Makefile.f2o)を使用すると、既に変換されたファイルの検出、並行して複数のコンバータプロセスを起動することができます。 – Kirill

答えて

0
for flacfiles in flacs: 
    if os.path.exists(os.path.splitext(flacfiles)[0] + '.cue')): 
     # do something 
+0

a:TypeError:Unicodeに強制する:必要な文字列またはバッファ、タプルが見つかりました –

関連する問題