Created
May 28, 2018 13:11
-
-
Save SharkyRawr/e10c1cc83a17addac7130e235277ba9c to your computer and use it in GitHub Desktop.
steam screenshot sorting script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| made by Sharky - https://sharky.pw/ | |
| """ | |
| import os, re, shutil | |
| from requests import get | |
| r = get('http://api.steampowered.com/ISteamApps/GetAppList/v2') | |
| apps = r.json()['applist']['apps'] | |
| def getappname(appid): | |
| global apps | |
| for app in apps: | |
| if app['appid'] == appid: | |
| return app['name'] | |
| files = os.listdir('.') | |
| for file in files: | |
| if not os.path.isfile(file): continue | |
| parts = file.split('_') | |
| if len(parts) < 3: continue | |
| appid = int(parts[0]) | |
| #print(appid) | |
| if appid <= 0: continue | |
| dirname = None | |
| try: | |
| appname = getappname(appid) | |
| safename = "".join([c for c in appname if re.match(r'[\w,\.,\s]', c)]) | |
| #print(safename) | |
| dirname = safename | |
| except Exception as ex: | |
| print(file, ex) | |
| continue | |
| if not os.path.isdir(dirname): | |
| os.mkdir(dirname) | |
| shutil.move(file, os.path.join(dirname, file)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment