[GRASS-user] List files and count

2011-01-10 Thread António Rocha

Greetings

I need to find, in a certain mapset, a list of files with a name that 
match a certain string and count them. How can I do this? I'm 
implementing this in a Py Script


Thanks
Antonio


__ Information from ESET NOD32 Antivirus, version of virus signature 
database 5774 (20110110) __

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user


Re: [GRASS-user] List files and count

2011-01-10 Thread Glynn Clements

António Rocha wrote:

 I need to find, in a certain mapset, a list of files with a name that 
 match a certain string and count them. How can I do this? I'm 
 implementing this in a Py Script

grass.script.mlist() provides an interface to g.mlist, although it
only supports glob patterns and not regexps. If you need regexps:

def mlist(type, pattern = None, mapset = None):
result = list()
for line in read_command(g.mlist,
 flags = 'r',
 type = type,
 pattern = pattern,
 mapset = mapset).splitlines():
result.append(line.strip())
return result

-- 
Glynn Clements gl...@gclements.plus.com
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user