I'm trying to write a batch command (Windows 10) that will copy an ArcGIS geodatabase to a new folder. I know this may seem like bad practice but it is part of a much larger project creation process which also includes non-GIS elements.

I can get batch files to copy normal folders and files using the

copy [origin] [destination]

command but the .gdb suffix of the geodatabase appears to break this.

If I try to copy the folder and include the .gdb suffix (i.e. as the folder appears in windows explorer) it creates a single file (of .gdb extension) rather than a folder with geodatabase elements inside.

Any thoughts?

ArcGIS Desktop 10.3

  • 1
    This is unwise for a number of reasons. Operating system copy will indiscriminately copy data which does not righly belong, including lock files, which impair your ability to use the data. – Vince Jan 4 '17 at 12:24

The Robocopy command is perfect for copying file geodatabases, and can even be used while the source gdb is in use as long as you exclude the lock files. It is built in to Windows, so can just be called from the command prompt.

robocopy path/to/source/gdb path/to/dest/gdb /s /xf *.lock

Using the /mt option greatly increases copy speed too, as copying takes place on multiple threads.

| improve this answer | |

You have to think of the FileGeodatabase as a Folder. So you have to copy it like it. But the copy command does not accept a .gdb as a folder. You have to create it first with the mkdir command and it works.

if not exist "C:\test\kopie\test.gdb" mkdir C:\test\kopie\test.gdb
copy C:\test\test.gdb\*  C:\test\kopie\test.gdb

But in general I would encourage you to use the PowerShell and not the Command-Shell. Microsoft will more and more switch from the old shell. Also PowerShell has more possibilities and with the ISE you have a very nice tool to build your commands.

The Copy-Item command also copies the .gdb correctly.

Copy-Item -Path  C:\test\test.gdb -Recurse -Destination C:\test\kopie
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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