Skip to content

Commit

Permalink
Minor improvement to code
Browse files Browse the repository at this point in the history
  • Loading branch information
RenanGreca committed Mar 24, 2019
1 parent 1e0d820 commit b6df7e0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions organize_screenshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,18 @@ def organize_screenshots(game_ids, input_dir, output_dir):
# Split the filename to find the game ID
image_id = image.split('-')[1].split('.')[0]

folder_name = image_id
if image_id in game_ids:
# If the ID was in the JSON file, create a directory using the game's title and copy the file
game_title = game_ids[image_id]
path = os.path.join(output_dir, game_title)
if not os.path.exists(path):
os.makedirs(path)
copy2(image, path)
# If the ID was in the JSON file, the directory is named with the title
folder_name = game_ids[image_id]
else:
# Otherwise, create a directory using the game's ID
not_found.append(image)
path = os.path.join(output_dir, image_id)
if not os.path.exists(path):
os.makedirs(path)
copy2(image, path)

# Create the directory and copy the file
path = os.path.join(output_dir, folder_name)
if not os.path.exists(path):
os.makedirs(path)
copy2(image, path)

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

0 comments on commit b6df7e0

Please sign in to comment.