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?

  • 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.
    – vadivelan
    May 7, 2012 at 14:16

4 Answers 4


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):
        shutil.copytree(src, dst)
    except OSError as exc: # python >2.5
        if exc.errno == errno.ENOTDIR:
            shutil.copy(src, dst)
        else: raise
  • 2
    Important to note that 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)! May 25, 2016 at 7:46
  • 1
    @Alex Tereshenkov mention you cant copy a GDB if they have lock files. This isnt exactly true. shutils ignore_patterns can be called inside of the copytree function to prevent copying of the .lock files. I am not sure if this causes any sort of data loss, but I have not seen any from the numerous times I have done it. Dec 17, 2020 at 2:11
  • @ThomasCallahan oh that's very useful - I don't think I've used it often. As you say, it's hard to tell what are the consequences of copying the file geodatabase files when it's in use, so this would not be likely a supported operation from Esri perspective. I wouldn't personally go this way ;) Dec 17, 2020 at 15:45

Another option:


import arcgisscripting

gp = arcgisscripting.create()

gp.Copy_management(r"C:\test.gdb", r"C:\test_COPY.gdb")
  • 3
    arcpy.Copy_management(r"inPath", r"outPath") for the arcpy method (version 10 as opposed to 9.3)
    – Roy
    May 7, 2012 at 13:08
  • Note: That when working over a Network this operation is very iffy. It will either, not work, work but report an 000260 Error, or if your lucky work with no errors. Mar 6, 2014 at 22:11

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):
                print "Da copy xong: %s" %(filegdb[0])
            except Exception as e:
                print e.message
            print "Da ton tai: %s" %(filegdb_name)
        print "Khong co FGB cua tinh %s" %(folder)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.