1

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

1
  • What error number does CalledProcessError indicate? Commented Dec 17, 2017 at 16:33

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.