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

asked Dec 17, 2017 at 16:26
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)
answered Dec 17, 2017 at 17:42
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.