Skip to content

Instantly share code, notes, and snippets.

@tmaybe
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmaybe/9363793 to your computer and use it in GitHub Desktop.
Save tmaybe/9363793 to your computer and use it in GitHub Desktop.
copy only the folders of a directory structure
import shutil
import os
# from http://stackoverflow.com/a/15664273/958481
def folders_only(dir, files):
return [f for f in files if os.path.isfile(os.path.join(dir, f))]
folderin = './hello'
folderout = './goodbye'
shutil.copytree(folderin, folderout, ignore=folders_only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment