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
asked Dec 17, 2017 at 16:26
Tspm1eca
4131 gold badge4 silver badges7 bronze badges
1 Answer 1
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)
answered Dec 17, 2017 at 17:42
Bakhrom Rakhmonov
7026 silver badges15 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
CalledProcessErrorindicate?