2011-10-29 3 views
0

나는 작업 디렉토리에는 OGG 모든 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 하나 인 .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

받기 : TypeError : 유니 코드로 강제 변환 : 문자열 또는 버퍼 필요, 튜플을 찾음 –