Skip to content

Commit 1e0d820

Browse files
committed
Preparing release 2.0.0
1 parent ce10ac4 commit 1e0d820

File tree

3 files changed

+83
-31
lines changed

3 files changed

+83
-31
lines changed

README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Written by Renan Greca in 2017.
55
This code is free to distribute and alter.
66

77
## Download
8-
The latest stable release is 1.2.0. Download the Python file (Mac or Linux) or the Windows executable here:
8+
The latest stable release is 2.0.0. Download the Python file (Mac or Linux) or the Windows executable here:
99

1010
https://github.com/RenanGreca/Switch-Screenshots/releases/tag/v1.2.0
1111

@@ -16,12 +16,16 @@ https://github.com/RenanGreca/Switch-Screenshots/releases
1616

1717
## Usage
1818
Place the program and the `game_ids.json` file in the same directory as the
19-
Switch's Album folder, either on
20-
the microSD card or on your computer after transferring the Album.
19+
Switch's Album folder, either on the microSD card or on your computer after
20+
transferring the Album.
2121

2222
After running, all screenshots will be placed within directories according to
2323
which game they are from. They can be found within the Output directory.
2424

25+
If the game is currently not in the IDs file, a folder will be created using
26+
the game ID instead of title. You can rename it but please contribute the ID
27+
to the repository by filing an issue or pull request.
28+
2529
### Windows
2630
Double-click `organize_screenshots.exe`.
2731

@@ -37,19 +41,27 @@ On a terminal, run:
3741
python organize_screenshots.py
3842
```
3943

44+
#### Optional parameters:
45+
46+
* `-i INPUT_DIR`: Specifies location of the Album directory. Default: `./Album/`.
47+
* `-o OUTPUT_DIR`: Specifies desired output directory. Default: `./Output/`.
48+
4049
## About the game IDs
4150

4251
Switch screenshots are stored in the following format: `[timestamp]-[game id].jpg`.
43-
Therefore, we can use the filenames to figure out which game it was from.
52+
Therefore, we can use the filenames to figure out from which game it was taken.
4453

4554
For example, the screenshot `2017030619573600-F1C11A22FAEE3B82F21B330E1B786A39.jpg`
4655
was taken on March 6, 2017 in the game The Legend of Zelda: Breath of the Wild.
4756
Some titles may have more than one ID, depending on the region or version. Demos
4857
also have their own IDs.
4958

5059
The Switch UI contains multiple IDs, for different parts of the UI (home menu,
51-
friends list, system settings, etc.). For simplicity, I've labeled all those
52-
IDs as "Nintendo Switch".
60+
friends list, system settings, etc.). For simplicity, I've labeled all those
61+
IDs as "Nintendo Switch".
62+
63+
Today, the Switch saves files as JPG (screenshots) or MP4 (recordings). The program
64+
also supports PNG files in case Nintendo ever adds lossless screenshots.
5365

5466
The `game_ids.json` file follows this format:
5567
```
@@ -61,7 +73,7 @@ The `game_ids.json` file follows this format:
6173

6274
## Contributing
6375

64-
The initial version of `game_ids.json` contains only the titles I have played.
76+
The initial version of `game_ids.json` contained only the titles I have played.
6577
If you have a screenshot for a game that is not on this list, the program will
6678
output a warning telling you which screenshot it was.
6779

@@ -73,5 +85,6 @@ The Windows `.exe` was generated using PyInstaller.
7385

7486
## Discussion
7587

76-
If you want to discuss the program or ask questions about it, please check out
77-
the [Reddit thread at /r/NintendoSwitch](https://www.reddit.com/r/NintendoSwitch/comments/6rcttl/i_made_a_program_to_organize_switch_screenshots/) or tweet at me [@RenanGreca](https://twitter.com/RenanGreca). :)
88+
If you want to discuss the program or ask questions about it, create an issue, check out the
89+
[Reddit thread at /r/NintendoSwitch](https://www.reddit.com/r/NintendoSwitch/comments/6rcttl/i_made_a_program_to_organize_switch_screenshots/)
90+
or send me a tweet [@RenanGreca](https://twitter.com/RenanGreca). :)

game_ids.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"D6F3EB1178A90392C0B8A57476DADED0": "Axiom Verge",
1919
"C0A771DA35FEA8B9400647F18EA0169B": "Axiom Verge",
2020

21+
"EAD9CDD267F449963C89657382E411AE": "Baba is You",
2122
"56A9001957E1FA9E6227F5C3F7F107DC": "Banner Saga 2",
2223
"79EC1189088E767339D21942767BCF2E": "Battle Chef Brigade",
2324
"E27E5ADA5A86332E7C52B3562FCF5A27": "Bayonetta 2",
@@ -33,6 +34,7 @@
3334
"A6C056CABE0E1894654A3769FAF6D11E": "Captain Toad's Treasure Tracker",
3435
"93FA958835AC3573C5186D5F5B0DB6B2": "Cave Story+",
3536
"75A32021BE3512D7AA96B2D72F764411": "Celeste",
37+
"BBBCE85F6EBFFC9C493F35F910EE935B": "ChromaGun - Demo",
3638
"03F6D2DE86ACBC923C87A67D746E299C": "Clustertruck",
3739

3840
"EA5CEAD0C10C4580E4DCED858DDFCF69": "Dandara",
@@ -168,6 +170,7 @@
168170
"8AEDFF741E2D23FBED39474178692DAF": "Super Mario Odyssey",
169171
"099ECEEF904DB62AEE3A76A3137C241B": "Super Mario Party",
170172
"0E7DF678130F4F0FA2C88AE72B47AFDF": "Super Smash Bros. Ultimate",
173+
"C6D726972790F87F6521C61FBA400A1DX": "Super Smash Bros. Ultimate",
171174

172175
"691C9B2C6D1F1E032DDC01FD026159FD": "Tetris 99",
173176
"1B7686315C6209EBBD25E3E11E89316C": "The Binding of Isaac Afterbirth+",
@@ -191,6 +194,7 @@
191194
"404652E38014828AC0ED1A3EE2F1DEA3": "VOEZ",
192195
"993AC1F3383F4FF879FEA9A85677F9F9": "VVVVVV",
193196

197+
"B189E7FDF30356EC7B08C94ADE944BBB": "Wandersong",
194198
"E2DADADBE272660A316475FCCDECFECB": "Wonder Boy - The Dragon's Trap",
195199
"C4E9854DE59E1AAD6BFE8091E8A5B77D": "World of Goo",
196200

organize_screenshots.py

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,74 @@
33

44
# Place this script in the same directory as the Switch's Album folder.
55
# View README.md for more details.
6+
# More information: https://github.com/RenanGreca/Switch-Screenshots
67

78
import os
89
import json
910
from shutil import copy2
11+
import argparse
12+
import sys
1013

11-
# Create a list of all the image files in the Album directory.
14+
# Argument parser
15+
parser = argparse.ArgumentParser(description='''Nintendo Switch screenshot organizer.
16+
Identifies images and creates new directory structure based on game title.
17+
More information: https://github.com/RenanGreca/Switch-Screenshots''')
18+
parser.add_argument('-i', '--input_dir', type=str, required=False, default='./Album/',
19+
help='(str) Path to the Album directory. Default: ./Album/')
20+
parser.add_argument('-o', '--output_dir', type=str, required=False, default='./Output/',
21+
help='(str) Desired output directory. Default: ./Output/')
22+
23+
# Create a list of all the image/video files in the Album directory.
1224
# Thanks to L. Teder
1325
# https://stackoverflow.com/a/36898903
1426
def list_images(dir):
1527
r = []
16-
for root, dirs, files in os.walk(dir):
28+
for root, _, files in os.walk(dir):
1729
for name in files:
1830
if "jpg" in name or "mp4" in name or "png" in name:
1931
r.append(os.path.join(root, name))
2032
return r
2133

22-
# Load game IDs file
23-
with open('game_ids.json') as data_file:
24-
game_ids = json.load(data_file)
25-
26-
# Iterate over images
27-
for image in list_images('Album'):
28-
image_id = image.split('-')[1].split('.')[0]
29-
30-
if not os.path.exists('Output'):
31-
os.makedirs('Output')
32-
33-
# If the ID was in the JSON file, create a directory and copy the file
34-
if image_id in game_ids:
35-
game_title = game_ids[image_id]
36-
path = os.path.join('Output', game_title)
37-
if not os.path.exists(path):
38-
os.makedirs(path)
39-
copy2(image, path)
40-
else:
41-
print "Game ID not found for image", image
34+
def organize_screenshots(game_ids, input_dir, output_dir):
35+
images = list_images(input_dir)
36+
count = len(images)
37+
38+
not_found = []
39+
# Iterate over images
40+
for idx, image in enumerate(images):
41+
# Split the filename to find the game ID
42+
image_id = image.split('-')[1].split('.')[0]
43+
44+
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)
51+
else:
52+
# Otherwise, create a directory using the game's ID
53+
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)
58+
59+
# Print progress indicator
60+
sys.stdout.write("\r"+str(idx+1)+"/"+str(count))
61+
sys.stdout.flush()
62+
63+
if len(not_found):
64+
print("\nGame IDs not found for the following files:")
65+
print("\n".join(not_found))
66+
67+
if __name__ == '__main__':
68+
args = parser.parse_args()
69+
input_dir = args.input_dir
70+
output_dir = args.output_dir
71+
72+
# Load game IDs file
73+
with open('game_ids.json') as data_file:
74+
game_ids = json.load(data_file)
75+
76+
organize_screenshots(game_ids, input_dir, output_dir)

0 commit comments

Comments
 (0)