Oops, a silly bug:

On Fri, Aug 01, 2014 at 08:35:34AM +1000, Steven D'Aprano wrote:

> directory = '/path/to/the/directory'
> for track, filename in enumerate(os.listdir(directory), 1):
>     pathname = os.path.join(directory, filename)
>     subprocess.call(['ffmpeg', '-i', filename, str(track)+'.mp3'])

That should be pathname, of course:

    subprocess.call(['ffmpeg', '-i', pathname, str(track)+'.mp3'])

Also, be aware that the order of files coming from listdir is not 
guaranteed to be sorted in any specific fashion, so if you're renaming 
files like "3 blah blah blah.flac" to "7.mp3" you may end up a little 
confused :-)


-- 
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to