Renaming (include adding prefix or suffix) tons of feature classes/datasets/rasters/files ( The Power Of Phyton Part 4)
Hello,hey its been a while, today im going to post another phyton codes for your geoprocessing boooring routines. this time I will give short code that is very useful to batch renaming bunch of feature classes in your geodatabases.
The code itself just be done few minutes ago when I must renaming tons of feature classes in my current project at office (its about preparing basemap for 50.000 scale Infrastructure map)
so lets rideeee
Explanation :
1. Calling arcpy modules and env (environment), means ArcGIS will know that its phyton geoprocessing capabilities needs to be woken up.
2. Set Workspace , means This is the place your data currently hiding, call em!.
3. arcpy.listfeatureclassess() means, lets them marched and counted!
4. arcpy.Rename.management so on, means add 'batas_kabupaten' prefix into their name,
using this code, I succesfully rename 514 feature classess in just 60 seconds, cool isnt it?
The code itself just be done few minutes ago when I must renaming tons of feature classes in my current project at office (its about preparing basemap for 50.000 scale Infrastructure map)
so lets rideeee
# name = batch_renaming.py
# Description = rename feature classes in a feature dataset in a fast way
# Import System Modules
import arcpy
from arcpy import env
# Set Workspace
env.workspace = "E:/Workspace2015/BASEMAP_PII2015/Procdir/SBA Batas_admin_Kabupaten_2013_1/SBA.gdb"
# Calling All feature classess
list_Fcs = arcpy.ListFeatureClasses()
# And Call the Loop Processor
for name in list_Fcs:arcpy.Rename_management(name,('batas_kabupaten_'+name))
Explanation :
1. Calling arcpy modules and env (environment), means ArcGIS will know that its phyton geoprocessing capabilities needs to be woken up.
2. Set Workspace , means This is the place your data currently hiding, call em!.
3. arcpy.listfeatureclassess() means, lets them marched and counted!
4. arcpy.Rename.management so on, means add 'batas_kabupaten' prefix into their name,
using this code, I succesfully rename 514 feature classess in just 60 seconds, cool isnt it?
Comments
Post a Comment