Opened 14 years ago

Closed 10 years ago

#2783 closed enhancement (fixed)

Python utililities should support command-line wildcards

Reported by: Mike Taves Owned by: hobu
Priority: normal Milestone: 1.8.1
Component: Utilities Version: svn-trunk
Severity: minor Keywords: python, glob, gdal_merge, gdalident
Cc: antonio


At present, a command that uses wildcards does not work as expected, for example with

> -o test.tif 094a*
ERROR 4: `094a*' does not exist in the file system,
and is not recognised as a supported dataset name.

Traceback (most recent call last):
  File "C:\PROGRA~1\FWTOOL~1.1\bin\", line 358, in ?
    ulx = file_infos[0].ulx
IndexError: list index out of range

The present workaround is to use batch files and additional parameters (e.g.,

There are two solutions that should be used for all Python command line utilities:

Attachments (2) (580 bytes ) - added by Mike Taves 14 years ago.
patch for using fnmatch solution
glob_patch2.diff (2.4 KB ) - added by Mike Taves 13 years ago.
improvements to and using python glob module

Download all attachments as: .zip

Change History (10)

by Mike Taves, 14 years ago

Attachment: added

patch for using fnmatch solution

comment:1 by hobu, 13 years ago

Resolution: fixed
Status: newclosed

applied in the 1.6 branch in r16856 and in trunk in r16857. Thanks for the patch! I don't know that we'll generally support wildcards for all of the python utilities, but it sure makes sense for the merge operation in my mind.

comment:2 by Mike Taves, 13 years ago

Keywords: gdal_merge gdalident added; fnmatch removed
Resolution: fixed
Status: closedreopened
Type: defectenhancement
Version: 1.6.0svn-trunk

I've reviewed my comments and submission, and I'd like to improve on it. I was misinformed about the glob module, in that I misread it was introduced in Python 2.5. The glob module was actually introduced in Python <=2.3 (I'm not sure how to check this history). The glob module really helps wildcard expansions, and should be used in place of fnmatch due to its ease of use.

I have also learned that wildcard expansion is only needed for MS-DOS BAT files. Of course, this is still of valid importance for many users.

Nevertheless, I've included a patch "glob_patch2.diff" using "svn diff" for both and These have been tested in MS-DOS and Linux. It is also much more simpler to read than the previous patch.

by Mike Taves, 13 years ago

Attachment: glob_patch2.diff added

improvements to and using python glob module

comment:3 by Mike Taves, 13 years ago

Owner: changed from warmerdam to hobu
Status: reopenednew

comment:4 by hobu, 13 years ago

Resolution: fixed
Status: newclosed

Applied in trunk in r17632 and backported in r17633. Please reopen if this is not working.

comment:5 by warmerdam, 12 years ago

Resolution: fixed
Status: closedreopened


Globbing of arguments to or any other scripts by default is inappropriate as some objects are not in the filesystem as detailed in:

I think the globbing needs to be backed out or only applied when a -glob or -wildcard switch is passed in.

comment:6 by antonio, 12 years ago

Cc: antonio added

comment:7 by warmerdam, 10 years ago

As above, and per (#4542) this auto-globbing breaks non-simple files. I will apparently have to back it out myself.

comment:8 by warmerdam, 10 years ago

Resolution: fixed
Status: reopenedclosed

all globbing changes backed out in trunk (r24064), 1.9 (r24063) and 1.8 (r24062). evil evil stuff.

If it is going to be reintroduced it needs to be respectful of non-simple files and likely should be windows only.

Note: See TracTickets for help on using tickets.