3 examples of 'copy folder python' in Python

Every line of 'copy folder python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
41def copy_folder(self, src, dest):
42 # IDEA: make recursion of the copy_list function for all child files of the dir?
43 # Create list of all the files
44 c = os.listdir(src)
45 contents = []
46 for it in c:
47 contents.append(os.path.join(src, it))
48 dirName = os.path.basename(os.path.normpath(src))
49 destDir = os.path.join(dest, dirName)
50 if os.path.isdir(destDir):
51 if self.dirForAllAction == '--':
52 resp = python_input(message='%s exists! AppendName(a), Mege(m), Skip(s)? Default=a, add "all" to do for all' % dirName)
53 if len(resp) > 1:
54 resp = resp[0]
55 self.dirForAllAction = resp
56 else:
57 resp = self.dirForAllAction
58 # Take action on what to do with the folder depending on op
59 if resp == 'a':
60 # Create a new folder with an unique name
61 upath = self.uniquify(os.path.join(dest, dirName))
62 os.makedirs(upath)
63 destDir = upath
64 elif resp == 's':
65 # Skip this dir
66 return
67 elif resp == 'm':
68 # Merge doesn't need any logic
69 pass
70 else:
71 # Path doesn't exist so lets make it
72 os.makedirs(destDir)
73 # Do the copy
74 self._copy_list(contents, destDir)
54def copySourceFiles(folder):
55 subprocess.call(mkdir + ' resources' + slash + 'plugins' + slash + 'source_files' + slash, shell=True)
56 print("Copying Source Files: " + folder)
57 subprocess.call(copyTree + ' ' + folder + slash + 'plugins' + slash + '*.java' + ' resources' + slash + 'plugins' + slash + 'source_files' + slash, shell=True)
252def copydir(src, dst, with_src=True):
253 # Example call: scp -r foo your_username@remotehost.edu:/some/scripts/directory/bar
254 # print("Transfering files ...")
255 mkdirs(dst)
256 if not with_src:
257 src += '/'
258 subprocess.call(['rsync', '-uz', '-r', '-l', src, dst]) # scp / rsync, z compress, u update-mode

Related snippets