'How can I tell subprocess to answer "y" to a commandline question?
I'm automating an ffmpeg command but when the file exists already, it asks me if I have to "Overwrite [y/N]" and it stalls the entire script until I have to enter "y" myself in the console. How can I automate that?
for file in all_files_in_dir:
output = file.split('.')[0]
subprocess.call(f'ffmpeg -hide_banner -i {file} -map 0:s:1 {output}.srt')
I have to enter "y" myself (as seen in green), then press enter everytime a file is already found. The answer will be "y", so I can hardcode the answer "y" if need be.
Solution 1:[1]
Add -y
to ffmpeg args. Add -n
for no.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Gyan |