Litwos Litwos - 3 months ago 9
Python Question

Get specific file with glob

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

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

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

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