Created
May 14, 2018 21:06
-
-
Save nunenuh/b8f5e6334ca5616b665d6368553eb907 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from pathlib import Path | |
| from shutil import copyfile | |
| srcdir = '/home/nunenuh/research/fase2/data/new/' | |
| dstdir = '/home/nunenuh/research/fase2/data/new/combined/' | |
| def copyalltoo(srcdirz, dstdirz, verbose=False): | |
| #create directory if exists | |
| dst = Path(dstdirz) | |
| if not dst.exists(): | |
| dst.mkdir(parents=True, exist_ok=True) | |
| if verbose==True: | |
| print("Creating Directory "+dstdirz) | |
| # traverse root directory, and list directories as dirs and files as files | |
| for root, dirs, files in os.walk(srcdirz): | |
| for file in files: | |
| srcpath = os.path.join(root, file) | |
| dstpath = os.path.join(dstdirz, file) | |
| if os.path.isfile(srcpath): | |
| copyfile(srcpath, dstpath) | |
| if verbose==True: | |
| print("copying file "+srcpath) | |
| copyalltoo(srcdir, dstdir, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment