Guest User

Untitled

a guest
Feb 19th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import arcpy
  2. import os
  3.  
  4. #Set parent directory
  5. arcpy.env.workspace = r'C:Folder1'
  6.  
  7. #List the subfolders in the parent directory
  8. workspaces = arcpy.ListWorkspaces("*", "Folder")
  9.  
  10. for workspace in workspaces:
  11. #Set new environment to list workspaces
  12. arcpy.env.workspace = workspace
  13. fgdbs = arcpy.ListWorkspaces("*", "FileGDB")
  14.  
  15. #Iterate through each FileGDB contained within and copy to destination
  16. for fgdb in fgdbs:
  17. #parsing the name from the full path of each FGDB
  18. #name = os.path.basename(fgdb).rstrip(os.path.splitext(fgdb)[1])
  19. name = os.path.basename(fgdb)[:-4]
  20. arcpy.Copy_management(fgdb, "C:/Folder1Copy/{0}.gdb".format(name))
Add Comment
Please, Sign In to add comment