Skip to content

Instantly share code, notes, and snippets.

@ileathan
Last active October 27, 2023 05:57
Show Gist options
  • Save ileathan/2e42c9d094aea1634dccca27b8a525ac to your computer and use it in GitHub Desktop.
Save ileathan/2e42c9d094aea1634dccca27b8a525ac to your computer and use it in GitHub Desktop.
A tinfoil shop in a nutshell (Rooted Nintendo Switches)
# A Tinfoil "shop" is just a collection of roms. You can place them in a directory and allow access to that directory via a simple server and your done.
# This code just loops through all the files and adds their name and filesize to a json that tinfoil likes so that it shows you file sizes.
# There are much more elaborate tools if you need just use this if you know what your doing or if I told you too.
#
# USAGE:
# bash tinfoilindex.sh "urlbase (internet link to the public facing directory with the games)" "Directory with all the games that is public facing (internet directory listing or such)" "Putput json file (serve it over http or however)"
# Example: tinfoilindex.sh "https://example.com/shop" "C:/SwitchGames" "C:/Server/public"
echo -e '{"files":[\n' >> c
i=0
for f in "$2"/*.{nsp,xci}; do
[[ i -eq 0 ]] && i=1 || echo -n "," >> c
l="$1/$(echo $f |grep -P '.*/\K.*')"
echo -e "{\n\"url\": \"$l\",\n\"size\": "$(stat "$f"|grep -oP "Size: \K\d+")"\n}" >> c
done
echo "]}" >> c; mv c "$3"/shop.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment