I have a program that processes files and returns another file as output. When I am running it in cmd I first set the path: "cd c:\program" and then set it to process the file located in the program folder: "program test.txt". I would like a python program to do it for me using the subprocess module, but I can't get it to work.
I have read the related posts and I know it should be a no-brainer, but as a novice I haven't been able to figure it out. Help greatly appriciated.
Here is one example of the code I tried. It runs, but doesn't produce any results.
import subprocess
textfile = 'c:\program\test.txt'
programPath = r'C:\program\program.exe'
subprocess.Popen([programPath, textfile])
Popenis not what you want. You might want to trysubprocess.check_call.