I would like to create a shape file containing the extents of each of the rasters in a directory. Is it possible to capture the extent of a raster using Python?

I have tried 
>>> extent1=arcgisscripting.Raster.extent('stg1_05.jpg')
Runtime error <type 'exceptions.TypeError'>: 'getset_descriptor' object is not callable
>>> 

and I can't seem to find any help on the module.

I also tried
>>> arcpy.RasterToPolygon_conversion(inRaster, outPolygons, "SIMPLIFY", field)

>Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 010247: The size of the output shapefile exceeds the 2 GB limit. ERROR 010067: Error in executing grid expression. Failed to execute (RasterToPolygon).

Anyway this will be a polygon of the whole raster file and not just the extents -even if this is generated, I guess we could then run a merge/dissolve but the files created are to big.

Another option I was thinking of was to convert the raster to layer
 

    import arcpy, glob, os, sys
    from arcpy import env, mapping
    path = os.getcwd()
    env.workspace = path
    RasterType = 'TIF'
    FileList = glob.glob(path + "\*." + RasterType)
    
    print 'Reading files from ' + path
    os.chdir(path)
    #print FileList
    
    x=0
    z=1005
    File=FileList[x]
    LayerWorking=arcpy.mapping.Layer(File)
    print File
    LayerExtent=LayerWorking.getExtent()
    XMAX = LayerExtent.XMax
    XMIN = LayerExtent.XMin
    YMAX = LayerExtent.YMax
    YMIN = LayerExtent.YMin
    pnt1 = arcpy.Point(XMIN, YMIN)
    pnt2 = arcpy.Point(XMIN, YMAX)
    pnt3 = arcpy.Point(XMAX, YMAX)
    pnt4 = arcpy.Point(XMAX, YMIN)
    array = arcpy.Array()
    array.add(pnt1)
    array.add(pnt2)
    array.add(pnt3)
    array.add(pnt4)
    array.add(pnt1)
    polygon = arcpy.Polygon(array)
    ShapeFile = path + "\Polygon_Extent" + "_" + str(z) + ".shp"
    print ShapeFile
    print arcpy.GetMessages()
    arcpy.CreateFeatureclass_management(path, ShapeFile, "POLYGON")
    print arcpy.GetMessages()
    arcpy.CopyFeatures_management(polygon, ShapeFile)

Gives following output

> Reading files from C:\Python26\script_tests\rectify
> C:\Python26\script_tests\rectify\Stage1_01a.TIF
> C:\Python26\script_tests\rectify\Polygon_Extent_1005.shp Executing:
> CopyFeatures in_memory\fB4DC2172_7D02_44B9_B55C_9E71427AE96E
> C:\Python26\script_tests\rectify\Polygon_Extent_1004.shp # 0 0 0 Start
> Time: Thu Jul 14 16:11:38 2011 Failed to execute. Parameters are not
> valid. ERROR 000725: Output Feature Class: Dataset
> C:\Python26\script_tests\rectify\Polygon_Extent_1004.shp already
> exists. Failed to execute (CopyFeatures). Failed at Thu Jul 14
> 16:11:38 2011 (Elapsed Time: 0.00 seconds) Traceback (most recent call
> last):   File "C:\Python26\script_tests\rectify\temp.py", line 36, in
> <module>
>     arcpy.CreateFeatureclass_management(path, ShapeFile, "POLYGON")   File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py",
> line 1539, in CreateFeatureclass
>     raise e ExecuteError: ERROR 999999: Error executing function. Failed to execute (CreateFeatureclass).
> 

using IDLE...Which is wierd as when you run it from the Python window in ArcMap it works fine when the Create/Copy feature commands are run individually.

> ShapeFile = "Polygon_Extent" + "_" + str(z) + ".shp"
> arcpy.CreateFeatureclass_management(path, ShapeFile, "POLYGON")

>> Result 'C:\\Python26\\script_tests\\rectify\\Polygon_Extent_1005.shp'>

>  arcpy.CopyFeatures_management(polygon, ShapeFile)
>> Result 'C:\\Python26\\script_tests\\rectify\\Polygon_Extent_1005.shp'>



this seems to be a very convoluted process...

PLEASE ADVISE