2

I need search a file from network driver (the folder contains twenty thousand or more files)

I tried use glob to search but is very slow. It usually needs 50s~60s to complete the search.

path = r'\\network\driver\'
file = '12AC9K-XXE-849*'
print(glob.glob(path+file))

I also tried use command line tools (all system is in Windows):

os.chdir(path)
print(os.system("dir 12AC9K-XXE-849*"))

I think the issues are in the network so I can not use cmd.exe because I will get the error message:

'\\network\driver\'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
The system cannot find the path specified.

Thanks tdelaney

finally i find answer and get "dir" value.

use subprocess

import subprocess

proc = subprocess.Popen(["dir/b", "\\network\driver\12AC9K-XXE-849*"], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
out = out.splitlines()
print out

get dir value anwser

thanks all help

Community
  • 1
  • 1
user1484400
  • 119
  • 1
  • 2
  • 13

0 Answers0