Skip to content

Instantly share code, notes, and snippets.

@st-le
Created September 25, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st-le/6c1a9d134c69790fa9e0aa190b9abfc9 to your computer and use it in GitHub Desktop.
Save st-le/6c1a9d134c69790fa9e0aa190b9abfc9 to your computer and use it in GitHub Desktop.
list folders and copy files with python pathlib, os.path, shutil
import os.path as osp
from pathlib import Path
import shutil as st
print ('hello world')
dir = Path('../benchmark_frames/')
all_path = []
all_path.append(list(dir.glob('[0-9]')))
all_path.append(list(dir.glob('[0-9][0-9]')))
all_path.append(list(dir.glob('[0-9][0-9][0-9]')))
for list_p in all_path:
for p in list_p:
dirname = osp.basename(p)
# print(str(p) + " " + dirname)
dir = Path(p)
fl = list(dir.glob('imgTexture.bmp'))
print ('\n')
for f in fl:
print (f)
dst = '.\\Rgb_only\\' + dirname + '.bmp'
print(dst)
st.copy(f, dst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment