Skip to content

Commit b6df7e0

Browse files
committed
Minor improvement to code
1 parent 1e0d820 commit b6df7e0

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

organize_screenshots.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,18 @@ def organize_screenshots(game_ids, input_dir, output_dir):
4141
# Split the filename to find the game ID
4242
image_id = image.split('-')[1].split('.')[0]
4343

44+
folder_name = image_id
4445
if image_id in game_ids:
45-
# If the ID was in the JSON file, create a directory using the game's title and copy the file
46-
game_title = game_ids[image_id]
47-
path = os.path.join(output_dir, game_title)
48-
if not os.path.exists(path):
49-
os.makedirs(path)
50-
copy2(image, path)
46+
# If the ID was in the JSON file, the directory is named with the title
47+
folder_name = game_ids[image_id]
5148
else:
52-
# Otherwise, create a directory using the game's ID
5349
not_found.append(image)
54-
path = os.path.join(output_dir, image_id)
55-
if not os.path.exists(path):
56-
os.makedirs(path)
57-
copy2(image, path)
50+
51+
# Create the directory and copy the file
52+
path = os.path.join(output_dir, folder_name)
53+
if not os.path.exists(path):
54+
os.makedirs(path)
55+
copy2(image, path)
5856

5957
# Print progress indicator
6058
sys.stdout.write("\r"+str(idx+1)+"/"+str(count))

0 commit comments

Comments
 (0)