Created
October 15, 2020 11:56
-
-
Save daguiam/43f1e5eae370f0cb674aa032aaf51784 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 | |
def walk_levels(inputpath, outputpath, levels=1): | |
if levels==0: | |
return | |
else: | |
if not os.path.isdir(outputpath): | |
os.mkdir(outputpath) | |
for dirpath in os.listdir(inputpath): | |
newinput = os.path.join(inputpath, dirpath) | |
structure = os.path.join(outputpath, dirpath) | |
if not os.path.isdir(newinput): | |
continue | |
print(structure) | |
if not os.path.isdir(structure): | |
# print("creating dir") | |
os.mkdir(structure) | |
walk_levels(newinput, structure, levels-1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment