This worked for me, except the last part, but that can be done separately:
"""****************************************************************************
Name: RasterDomain
Description: This script uses theRaster Domain tool to generate polygon footprints for all
*.jpg rasters in a given workspace. In a second step two new Fields are created and populated
with the Filename and the Framenumber (part of the filename), then it appends all shapefiles
into a new created shapefile
****************************************************************************"""
#02.02.2015
#by F.Scharf
# Import system modules
import arcpy, os
from arcpy import env
from arcpy.sa import *
# Obtain a license for the ArcGIS 3D Analyst extension
arcpy.CheckOutExtension("3D")
arcpy.env.overwriteOutput = True
###Set local variables
InFolder = r"D:\Videoforgeoref\dolo3_neu3\trim"
# Dest = "D:/VideoTest_WS/C4dolo1_3/dest"
# Set environment settings
env.workspace = InFolder
try:
# Create the list of JPG rasters
rasterList = arcpy.ListRasters("*", "JPG")
print rasterList
# Verify there are rasters in the list
if rasterList:
# Loop the process for each raster
for raster in rasterList:
# Set Local Variables
outGeom = "POLYGON" # output geometry type
outPoly = "domain_" + raster[:-4] + ".shp" # names all output with the prefix "domain_", [:-4] strips the .jpg from the raster name
print "Creating footprint polygon for " + raster + "."
#Execute RasterDomain
arcpy.RasterDomain_3d(raster, outPoly, outGeom)
print "Finished Loop RasterDomain."
else:
"There are no JPG files in the " + env.workspace + " directory."
except:
# If an error occurred while running a tool print the messages
print arcpy.GetMessages()
"""*****************************************************************************
Here two fields are added, the Filename and - extracted from that - the frame
number (FrameNo) are calculated
******************************************************************************"""
#arcpy.env.workspace = r"D:\VideoTest_WS\C4dolo1_3\dest"
fcList = arcpy.ListFeatureClasses("domain*") # select all features starts with "domain"
fcs= []
pattern ="domain" # Select all features that have word "domain" in the name
#output = "D:\VideoTest_WS\C4dolo1_3\dest\merged"
for fcs in fcList:
print "processing " + fcs
# Define field name and expression
field1 = "FILENAME"
field2 = "FrameNo"
fcs_name = fcs[0:-4] ### populates field with the filename, the [0:-4] strips the .shp from the fcs name
fcs_no = fcs[31:-4] ### populates field with the frame number - here the last 8 to 5 places of the string ### fcs[:] NEEDS TO BE MODIFIED FOR EVERY NAMING FORMAT
# Create two new fields with a new name
arcpy.AddField_management(fcs, field1 ,"TEXT","","","35")
arcpy.AddField_management(fcs, field2 ,"LONG","","",10)
# Calculate fields here
arcpy.CalculateField_management(fcs, field1 , "\"" + fcs_name + "\"", "PYTHON")
arcpy.CalculateField_management(fcs, field2 , long(fcs_no) , "PYTHON")#"\"" + long(fcs_no) + "\"", "PYTHON")
print "field added and calculated"
'''*********************************************************************************
Here the before created RasterDomains-Polygon Shapefiles are Merged together (Appended - not working because
the Fields of the new created feature class do not fit the ones i the list - fields are lost -- here the
outLocation has to be different then the first workspace! because there is no selection of the shapefiles
to be appended and the "ERROR 000572: The output cannot be the same as input." appears
********************************************************************************'''
outLocation = r"D:\Videoforgeoref\dolo3_neu3\out_box" ### HERE THE OUTPUT LOCATION OF THE MERGED SHAPEFILE HAS TO BE DEFINED - SHOULD BE DIFFERENT THEN THE INFOLDER LOCATION
emptyFC = "MergedFootprints.shp" ### name of the new shapefile
try:
# Process: Create a new empty feature class to append shapefiles into
arcpy.CreateFeatureclass_management(outLocation, emptyFC, "POLYGON")
# All polygon FCs in the workspace are footprint shapefiles, we want to merge these to a new shapefile in another folder
fcList = arcpy.ListFeatureClasses("domain*","POLYGON") ### list will resemble [the shapes in the list] features classes starting with "domain"
print fcList
#Merge the Feature classes form the list
arcpy.Merge_management(fcList, outLocation + os.sep + emptyFC)
print "done with merging"
except:
# If an error occurred while running a tool print the messages
print arcpy.GetMessages()