Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading