I am trying to copy fgdb from one path to another using Python.
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
import arcgisscripting gp = arcgisscripting.create() gp.Copy_management(r"C:\test.gdb", r"C:\test_COPY.gdb")
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) ofgeodatabase = os.path.join(fgeodatabase,filegdb_name) if not arcpy.Exists(ofgeodatabase): try: arcpy.Copy_management(filegdb,ofgeodatabase) print "Da copy xong: %s" %(filegdb) except Exception as e: print e.message else: print "Da ton tai: %s" %(filegdb_name) else: print "Khong co FGB cua tinh %s" %(folder)
Pls. consider this in your python code. ( try to capture this error)
While doing manual copy of fGDB to another folder, pls. ensure you have not opened the fGDB in arcmap. It will throw an error "*.lock" file.