0

How can i copy a directory containing a particular file with particular extension in a variable in python Note that the file may be present in sub folder too. Since I am a beginner I would like to have some help...

Thanks in advance

  • See here: https://stackoverflow.com/questions/15034151/copy-directory-contents-into-a-directory-with-python – MackM Mar 06 '17 at 13:49
  • Please elaborate on what you need to do, because as-is your question is very difficult to understand. An example, and the code you have already tried may help us to understand. – Guillaume Mar 06 '17 at 14:31
  • Example : Source directory: "xx/yy/zz" and in this source directory let us consider there is a file with particular extension say .zip. If that is the case then copy the source directory to destination directory. Note: THE SOURCE directory structure keeps on changes. I was trying to use os.walk to detect the .zip extension – Manojs toppalad Mar 07 '17 at 06:07

1 Answers1

1

Python code for this.

from distutils.dir_util import copy_tree

fromDirectory = "/user/"
toDirectory = "/windows/"

copy_to_file(fromDirectory, toDirectory)
lakeIn231
  • 1,177
  • 3
  • 14
  • 34