Copy directory tree without copying files

dwatrous daniel.watrous at gmail.com
Wed Sep 23 11:15:13 EDT 2009


Have you considered using os.walk?
http://docs.python.org/library/os.html#os.walk

It won't be completely automated, but I think it should allow you to
easily walk the directory structure to reproduce it in another
location.

If the file names/extensions are predictable you might also be able to
use the ignore attribute in the shutil.copytree function to prevent
copying files:
http://docs.python.org/library/shutil.html#shutil.copytree

Daniel

On Sep 23, 9:04 am, Jeremy Conlin <jlcon... at gmail.com> wrote:
> I am trying to copy a folder hierarchy from one location to another.
> I can use the shutil.copytree function to copy the folder tree, but I
> don't want the files copied, just the folders.  What is a good way to
> approach this?
>
> Thanks,
> Jeremy




More information about the Python-list mailing list