Skip to content

Instantly share code, notes, and snippets.

@VictorWesterlund
Created April 21, 2024 22:25
Show Gist options
  • Save VictorWesterlund/d92a0e7408ef6889920afe4449f22834 to your computer and use it in GitHub Desktop.
Save VictorWesterlund/d92a0e7408ef6889920afe4449f22834 to your computer and use it in GitHub Desktop.
import json
import os
from pathlib import Path
ALBUM_DIR = ""
def add_to_album(file, root, album):
album = bytes(album, "utf-8").decode("unicode-escape")
album_path = f"{ALBUM_DIR}/{album}"
if not os.path.exists(album_path):
os.makedirs(album_path)
Path(f"{album_path}/{file}").symlink_to(f"{root}/{file}")
with open('') as json_manifest:
manifest = json.load(json_manifest)
for root, subdirs, files in os.walk("._tst"):
for file in files:
if (file in manifest):
for album in manifest[file]:
add_to_album(file, root, album)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment