[Tutor] Using subprocess on a series of files with spaces

Peter Otten __peter__ at web.de
Fri Aug 1 01:37:32 CEST 2014


C Smith wrote:

I'd throw in a check to verify that filename is indeed a flac:

> or more accurately
> import os, subprocess, re
> directory = '/abs/path'
> for track, filename in enumerate(os.listdir(directory), 1):
>     pathname = os.path.join(directory, filename)
      if filename.endswith(".flac"):
          subprocess.call(['ffmpeg', '-i', pathname, filename[:-5]+'.mp3'])




More information about the Tutor mailing list