I am on OSX, which needs to escape spaces in filenames with a backslash. There are multiple files within one directory that all have the same structure, one or more characters with zero or more spaces in the filename, like this: 3 Song Title XYZ.flac. I want to use Python to call ffmpeg to convert each file to an .mp3. So far this is what I was trying to use: import os, subprocess track = 1 for filename in os.listdir('myDir'): subprocess.call(['ffmpeg', '-i', filename, str(track)+'.mp3']) track += 1
I am about to use re.sub to just replace all the '/s' with '\\/s', but is there a simpler/more pythonic way to do this? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor