0

我想将工作目录中的所有 FLAC 文件转换为 OGG:

这是我已经拥有的。

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

现在我想知道如何在包含我的 FLAC 文件的目录中检查是否有一个.flac带有 a.cue的情况,如果是这种情况 do_something()

4

1 回答 1

0
for flacfiles in flacs:
    if os.path.exists(os.path.splitext(flacfiles)[0] + '.cue')):
        # do something 
于 2011-10-29T10:38:46.577 回答