-1

I am trying to locate a specific .xml file with glob. But the path comes from an object, and it doesn't seem to work.

I followed this example: Python: How can I find all files with a particular extension?

The code is this:

import glob
ren_folder = 'D:\Sentinel\D\S2A_OPER_PRD_MSIL1C_PDMC_20160710T162701'
glob.glob(ren_folder+'/'s*.xml)

I get invalid syntax...

SyntaxError: invalid syntax

Community
  • 1
  • 1
Litwos
  • 1,278
  • 4
  • 19
  • 44

2 Answers2

2
glob.glob(ren_folder+'/'s*.xml)

You are closing the flie name string prematurely, it should be:

glob.glob(ren_folder+'/s*.xml')
DeepSpace
  • 78,697
  • 11
  • 109
  • 154
1

Does this work?

glob.glob(os.path.join(ren_folder, 's*.xml'))
DA--
  • 723
  • 1
  • 8
  • 20