Select to view content in your preferred language

best way to rename a folder using ArcPy

1186
2
Jump to solution
12-04-2018 08:21 AM
JasonFitzsimmons
Occasional Contributor

I run a Python script to delete and recreate a set of map services.  To do this, I place a folder with all the mxds and data in the same directory as the existing folder, with a different name. The script then renames the folder using os.rename, and then uses that data for the new map services.

The problem is, I get an 'Access Denied' error when I run this. The error is thrown when renaming the existing folder to 'folder_old'. If I restart the server, it will usually work, but this obviously is not ideal.  The server is an AWS instance, with ArcGIS 10.2.  I have full administrative rights on that machine, and I have IDLE set to run as an administrator.

Is there a preferred ArcPy method to rename a data folder that I should be using instead?

0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor

Hi Jason,

You can try the Rename tool.

View solution in original post

2 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Jason,

You can try the Rename tool.

JasonFitzsimmons
Occasional Contributor

I will try it, I had the impression that was used specifically for ArcGIS datasets -

from docs: Changes the name of a dataset. This includes a wide variety of data types, among them feature dataset, raster, table, and shapefile.

I also wonder why os.rename causes a problem, although I will not wonder so much if something else works..thanks!

0 Kudos