I am trying to copy fgdb from one path to another using Python.
copy(base.gdb,dest)
And got the message:
Error Info:
[Errno 13] Permission denied:
How to fix it?
I am trying to copy fgdb from one path to another using Python.
copy(base.gdb,dest)
And got the message:
Error Info:
[Errno 13] Permission denied:
How to fix it?
As far as a file system is concerned, a file gdb is a directory - trying to copy one as a single file will not work. Try this out:
import shutil, errno
def copyanything(src, dst):
try:
shutil.copytree(src, dst)
except OSError as exc: # python >2.5
if exc.errno == errno.ENOTDIR:
shutil.copy(src, dst)
else: raise
copytree
won't able to copy the file geodatabase contents if there are any .lock
files there - you will get a permission denied error. The Copy
GP tool will copy the geodatabase even if there are locks there (a user has open a feature class properties window or just navigate in the geodatabase in the Catalog window)!
Commented
May 25, 2016 at 7:46
Another option:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000051000000
import arcgisscripting
gp = arcgisscripting.create()
gp.Copy_management(r"C:\test.gdb", r"C:\test_COPY.gdb")
arcpy.Copy_management(r"inPath", r"outPath")
for the arcpy method (version 10 as opposed to 9.3)
Make sure that the person running the python script has permission to create additional folders in the directory the script is run from.
What type of system are you running the script on? Where in the PATH are you trying to run the script from?
i made a simple script to copy geodatabases in-sub folders.It runs quite well. Hope this helps
import sys, arcpy, os
input_folder = "pro_mdb"
output_folder = "file-geodatabase"
curr_file = os.getcwd()
pro_mdb = os.path.join(curr_file,input_folder)
fgeodatabase = os.path.join(curr_file,output_folder)
folders = os.listdir(pro_mdb)
for folder in folders:
arcpy.env.workspace = os.path.join(pro_mdb,folder)
filegdb = arcpy.ListWorkspaces("*","FileGDB")
if len(filegdb) > 0:
filegdb_name = os.path.basename(filegdb[0])
ofgeodatabase = os.path.join(fgeodatabase,filegdb_name)
if not arcpy.Exists(ofgeodatabase):
try:
arcpy.Copy_management(filegdb[0],ofgeodatabase)
print "Da copy xong: %s" %(filegdb[0])
except Exception as e:
print e.message
else:
print "Da ton tai: %s" %(filegdb_name)
else:
print "Khong co FGB cua tinh %s" %(folder)