Reputation: 403
I try to use "ren" command with Python 3.6.3 subprocess in Windows
Code:
import subprocess, os
path = r"C:\Users\user\Desktop\Temp"
subprocess.check_output(["ren", os.path.join(path, "ABC.txt"), os.path.join(path, "Hello.txt")], shell=True)
but I get Error: "subprocess.CalledProcessError"
Please help!!
thanks
Upvotes: 1
Views: 396
Reputation: 702
According to the ren command manual you can set only filename that you need to change current file not drive and folder:
try fixed code
import subprocess, os
path = r"C:\Users\user\Desktop\Temp"
subprocess.check_output(["ren", os.path.join(path, "ABC.txt"), "Hello.txt"], shell=True)
Upvotes: 3