Skip to content

Commit

Permalink
Fix variable name and add exist_ok=True
Browse files Browse the repository at this point in the history
  • Loading branch information
lpozo committed Dec 18, 2024
1 parent 57344e7 commit c16e853
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python-get-all-files-in-directory/create_large_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ class Item:

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

if not item.children and not item.junk_files:
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)
return

root = path_to.joinpath(item.name)
root.mkdir()
root.mkdir(exist_ok=True)

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

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


create_item(folder_structure)

0 comments on commit c16e853

Please sign in to comment.