AnsweredAssumed Answered

Copy rasters through python scripting

Question asked by ahsan_phy@hotmail.com on Dec 20, 2014
Latest reply on Dec 23, 2014 by ahsan_phy@hotmail.com

I want to copy all the rasters from folder in to Geodatabase with same name how can i do it, i tried through given script but does not copy with it's original name, what is problem in my code ? please help me ?

 

import arcpy

from arcpy import env

env.workspace = "      "

rasterlist = arcpy.ListRasters()

for raster in rasterlist:

    desc = arcpy.Describe(raster)

    base_ext = desc.extension

    if base_ext == '' ":

        name = str(desc.basename)

        arcpy.CopyRaster_management(name, CopyResults.gdb/name","DEFAULTS","0","9","","","8_BIT_UNSIGNED")

    else:

        name = str(desc.basename) + "." + str(desc.extension)

        name1 = str(desc.basename)

        arcpy.CopyRaster_management(name, CopyResults.gdb/name1","DEFAULTS","0","9","","","8_BIT_UNSIGNED")

    print name

   

print "Copy all rasters successfully."

Outcomes