Background
I use the command dir/s
in batch files all the time. But, I am unable to call this using python. NOTE: I am
You need a space between dir
and /s
. So break it into an array of 2 elements. Also as carlosdoc pointed out, you would need to add shell=True, since the dir
command is a shell builtin.
import subprocess
subprocess.call(["dir", "/s"], shell=True)
But if you're trying to get a directory listing, make it OS independent by using the functions available in the os
module such as os.listdir()
, os.chdir()