How to access Shapefile metadata using OGR?

ogrinfo can shorten the output considerably using the -so flag.

-so: Summary Only: supress listing of features, show only the summary information like projection, schema, feature count and extents.

So ogrinfo -ro -so file.shp should give a summary of the metadata.

And

-al: List all features of all layers (used instead of having to give layer names as arguments).

Would certainly give you a lot of info on the other hand if used by itself!

And if you want to see metadata for individual or a range of features, there is the -fid, -where, and -sql flags which do that.

Lastly, -geom will act as a master toggle for the geometry info.

-geom={YES/NO/SUMMARY}: (starting with GDAL 1.6.0) If set to NO, the feature dump will not display the geometry. If set to SUMMARY, only a summary of the geometry will be displayed. If set to YES, the geometry will be reported in full OGC WKT format. Default value is YES.

There is a FAQVector Wiki with examples for GDAL command line utilities that also gives some other tips =)


You may try:

ogrinfo -al USA_adm0.shp >> output.txt

All the information will be redirected into a text file called output.txt in the folder in which the command was invoked (but a richer relative or absolute path can also be used)