We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 57344e7 + c16e853 commit 6301b57Copy full SHA for 6301b57
python-get-all-files-in-directory/create_large_dir.py
@@ -66,18 +66,18 @@ class Item:
66
67
def create_item(item: Item, path_to: Path = Path.cwd()) -> None:
68
69
- if not item.children and not item.junk_files:
70
- path_to.joinpath(item.name).touch()
+ if not item.children and not item.num_junk_files:
+ path_to.joinpath(item.name).touch(exist_ok=True)
71
return
72
73
root = path_to.joinpath(item.name)
74
- root.mkdir()
+ root.mkdir(exist_ok=True)
75
76
for child in item.children:
77
create_item(child, path_to=root)
78
79
for i in range(item.num_junk_files):
80
- root.joinpath(f"{i}.txt").touch()
+ root.joinpath(f"{i}.txt").touch(exist_ok=True)
81
82
83
create_item(folder_structure)
0 commit comments