Steven D'Aprano wrote: > Also, this only looks in the C:.../XYZ directory. I think that Python 3.4 > or better will accept a ** wildcard instead of * to look in subdirectories > too.
Unfortunately that's Python 3.5. You are ahead of time. > Actually, I think you don't need the shell argument. Try this instead: > > path = "c:/abc/def/ghj/main/features/XYZ/*" + str(tempID) + ".cli" > output = subprocess.check_output(['dir', '/s', '/b', path]) "dir" used to be an internal command; back in the day you would have to invoke it with (untested) check_output(["cmd", "/k", 'dir', '/s', '/b', path]) I believe on Windows path may contain wildcards -- or does subprocess escape these somehow? > That is likely to be safer and will help avoid shell injection attacks if > the path comes from an untrusted source. Any subprocess experts want to > confirm this? I probably should have kept quiet to let a combined subprocess/windows expert chime in -- but now it's too late... -- https://mail.python.org/mailman/listinfo/python-list