Skip to content

Instantly share code, notes, and snippets.

@J-Swift
Last active April 10, 2022 21:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save J-Swift/7fad6ac59624aa6d0d1b2e3a821eb800 to your computer and use it in GitHub Desktop.
Save J-Swift/7fad6ac59624aa6d0d1b2e3a821eb800 to your computer and use it in GitHub Desktop.
Detect what retropie rom directories dont have all their metadata
#!/usr/bin/env bash
readonly target_dir="${1:-}"
if [ -z "${target_dir}" ] || ! [ -d "${target_dir}" ]; then
echo "ERROR: doesnt exist or isnt a directory [${target_dir}]"
exit 1
fi
readonly RED=$( tput setaf 1 )
readonly GREEN=$( tput setaf 2 )
readonly YELLOW=$( tput setaf 3 )
readonly RESET=$( tput sgr0 )
has_gamelist() {
local -r dir="${1}"
[ -f "${dir}/gamelist.xml" ]
}
has_images() {
local -r dir="${1}"
[ -d "${dir}/images" ]
}
is_empty_dir() {
local -r dir="${1}"
# https://superuser.com/a/352387
[ -n "$( find "${dir}" -maxdepth 0 -type d -empty 2>/dev/null )" ]
}
main() {
for rom_dir in "${target_dir}"/*; do
if is_empty_dir "${rom_dir}"; then
echo -e "${YELLOW}- ${rom_dir} (empty)${RESET}"
else
echo "- ${rom_dir}:"
if has_gamelist "${rom_dir}"; then
echo -e " ${GREEN}✓ Gamelist${RESET}"
else
echo -e " ${RED}✗ Gamelist${RESET}"
fi
if has_images "${rom_dir}"; then
echo -e " ${GREEN}✓ Images${RESET}"
else
echo -e " ${RED}✗ Images${RESET}"
fi
fi
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment