Move shapefile from one folder to another using python

3381
3
Jump to solution
10-11-2013 08:26 AM
DanielJimenez2
New Contributor III
I'm working with shapefiles and using the ArcPy library. My script is creating a new shapefile based on a join and I want to know how to move the newly joined-shapefile from the environment location to a new folder. Any ideas on how to do this?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JasonScheirer
Occasional Contributor III
import os  import arcpy  shapeFileName = r"c:\some\output.shp" outFeature = os.path.join(r"c:\new\folder", os.path.basename(shapeFileName)) arcpy.CopyFeatures_management(shapefileName, outFeature)

View solution in original post

0 Kudos
3 Replies
JasonScheirer
Occasional Contributor III
You can use the copy tool, and then the delete tool on the old file. Though it would make more sense just to write the shapefile to the final destination to start with.
0 Kudos
DanielJimenez2
New Contributor III
If i want to write the shapefile to a different destination would i do that it in the outfeature parameter. Do i just add the path of the new folder in my function? I guess i don't know how to work with different folders in here. How to i specify where to folder?

arcpy.CopyFeatures_management(shapefileName, outFeature)
0 Kudos
JasonScheirer
Occasional Contributor III
import os  import arcpy  shapeFileName = r"c:\some\output.shp" outFeature = os.path.join(r"c:\new\folder", os.path.basename(shapeFileName)) arcpy.CopyFeatures_management(shapefileName, outFeature)
0 Kudos