Skip to content

Instantly share code, notes, and snippets.

@CookiePLMonster
Last active March 25, 2019 19:14
Show Gist options
  • Save CookiePLMonster/79b5f5d0af8f37a5427c3b35d8e00f9c to your computer and use it in GitHub Desktop.
Save CookiePLMonster/79b5f5d0af8f37a5427c3b35d8e00f9c to your computer and use it in GitHub Desktop.
Flatten Vita's SCREENSHOT directory, and unhide files
import os
import sys
import subprocess
extensions = [".png", ".jpg", ".bmp"]
rootpath = os.path.normpath(os.path.join(sys.argv[1], os.sep, 'picture', 'SCREENSHOT')) if len(sys.argv) > 1 else '.'
dir_list = os.walk(rootpath)
next(dir_list) # Skip root path
for root, dirs, files in dir_list:
dirname = os.path.basename(root)
if len(dirname) == 2 and dirname.isalpha() and dirname.islower():
for file in files:
_, extension = os.path.splitext(file)
if extension.lower() in extensions:
print('Moving ' + file + '...')
srcpath = os.path.join(root, file)
destpath = os.path.join(rootpath, file)
os.rename(srcpath, destpath)
if not os.listdir(root):
print(root + ' is empty, removing...')
os.rmdir(root)
try:
for ext in extensions:
subprocess.call(["attrib", "-s", "-h", "/s", os.path.join(rootpath, '*' + ext)], stdout=subprocess.DEVNULL)
except FileNotFoundError:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment