Skip to content

Instantly share code, notes, and snippets.

@nunenuh
Created May 14, 2018 21:06
Show Gist options
  • Save nunenuh/b8f5e6334ca5616b665d6368553eb907 to your computer and use it in GitHub Desktop.
Save nunenuh/b8f5e6334ca5616b665d6368553eb907 to your computer and use it in GitHub Desktop.
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