Akos. prestigio Akos. prestigio - 3 years ago 198
Python Question

Python using windows command line

I have this python code:

import os
os.system('cd C:\yt')
os.system("ffmpeg.exe -i test.mp4 newfilename.mp3")

The yt folder include the ffmeg.exe and test.mp4 but I write the code apart on cmd everthing is working but thus I get this error message:

'ffmpeg.exe' is not recognized as an internal or external command,
operable program or batch file.

if I use C:\yt\ffmpeg.exe -i test.mp4 newfilename.mp3 is not working and if i use only os.system('cd C:\yt') i not get error message.
What's wrong with my code?

Answer Source

You need to move to that directory. Try the following:

import os
print os.getcwd() # confirm location
os.system("ffmpeg.exe -i test.mp4 newfilename.mp3")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download