Skip to content

Commit c16e853

Browse files
committed
Fix variable name and add exist_ok=True
1 parent 57344e7 commit c16e853

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

python-get-all-files-in-directory/create_large_dir.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ class Item:
6666

6767
def create_item(item: Item, path_to: Path = Path.cwd()) -> None:
6868

69-
if not item.children and not item.junk_files:
70-
path_to.joinpath(item.name).touch()
69+
if not item.children and not item.num_junk_files:
70+
path_to.joinpath(item.name).touch(exist_ok=True)
7171
return
7272

7373
root = path_to.joinpath(item.name)
74-
root.mkdir()
74+
root.mkdir(exist_ok=True)
7575

7676
for child in item.children:
7777
create_item(child, path_to=root)
7878

7979
for i in range(item.num_junk_files):
80-
root.joinpath(f"{i}.txt").touch()
80+
root.joinpath(f"{i}.txt").touch(exist_ok=True)
8181

8282

8383
create_item(folder_structure)

0 commit comments

Comments
 (0)