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]'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.

enter image description here

>Solution :

Add -y to ffmpeg args. Add -n for no.

Leave a Reply