Reputation: 11
I'm trying to pass a directory to glob which will be read to a variable from a config file.
If I just do this it works fine:
path = '//Server/Company/Official Documents/**/*.pdf'
Files = glob.glob(path,recursive=True)
But if I try to do this I get an empty list:
path = Config[1][1]
Files = glob.glob('{path}**/*.pdf'.format(path=path),recursive=True)
For information,
print(Config [1][1])
gives this
'//Server/Company/Official Documents/'
Upvotes: 1
Views: 2066
Reputation: 971
You are missinng / in '{path}**/*.pdf'.format(path=path) Try changinng it to:
'{path}/**/*.pdf'.format(path=path1)
like:
glob.glob('{path}/**/*.pdf'.format(path=path),recursive=True)
Upvotes: 1