Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

5 Answers

up vote 12 down vote accepted

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
share|improve this answer
    
Yeap. that's it. copytree works, just copy does not. Tnx:) –  Z77 May 6 '12 at 16:15
add comment

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)
share|improve this answer
add comment

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.

share|improve this answer
add comment

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")
share|improve this answer
1  
arcpy.Copy_management(r"inPath", r"outPath") for the arcpy method (version 10 as opposed to 9.3) –  Roy May 7 '12 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. –  TForward Mar 6 at 22:11
add comment

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?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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