Find if a file existing within 1000s of folder/sub-folder - each file has a unique presence

chaotic.sid at gmail.com chaotic.sid at gmail.com
Thu May 21 01:34:34 EDT 2015


Hi All,

I have a list of scripts which are present in various folders and this may be present in one of their sub-folder too.
There are 1000s of folders and hence parsing through each folder/sub-folder is not an option.

So I was trying to dir /s /b using python.
Now since the file's path name is computed using other part of the code, I am feeding in a variable here and somehow it does not seem to work.. :(

Intent is to run following command from python 
dir /s /b "c:/abc/def/ghjmain\features\XYZ\*<filename>"

My present code.
import subprocess

for row in range(1,max_row):
	tempID_cell = "C" + str(row);
	tempID = ws[tempID_cell].value;
	print (tempID);
	Command = "c:\\abc\\def\\ghj\\main\\features\\XYZ\\*" + str(tempID) + ".cli";
	print (Command);
	IsPresent = subprocess.check_output("dir /s /b Command", shell=True);

Any help would really be appreciated.

Regards,
Siddharth



More information about the Python-list mailing list