From f938ce931fff22792001f09bb38f71d264676a82 Mon Sep 17 00:00:00 2001 From: "Michael T. DeGuzis" Date: Tue, 27 Feb 2024 23:00:32 +0000 Subject: [PATCH] Add mame export/import --- utilities/move-mame-roms.sh | 51 +++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 utilities/move-mame-roms.sh diff --git a/utilities/move-mame-roms.sh b/utilities/move-mame-roms.sh new file mode 100755 index 00000000..fa46aef8 --- /dev/null +++ b/utilities/move-mame-roms.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Description: +# This script can move roms in and out of "roms.archived" in +# the folder it's placed in (e.g. roms/mame). It accepts a txt +# download from http://adb.arcadeitalia.net/lista_mame.php, and +# will match the export against what is in roms.archived or the +# current folder (based on operation value or "archive" or "unarchive". +# + +# http://adb.arcadeitalia.net/lista_mame.php + +# The rom list should have the string to match, one per line +archive="roms.archived" +operation=$1 +romlist=$2 + +if [[ -z "${operation}" ]]; then + echo "[ERROR] Missing operation as arg 1! One of: archive, unarchive" + exit 1 +fi +if [[ -z "${romlist}" ]]; then + echo "[ERROR] Missing rom list to parse as arg 2!" + exit 1 +fi + +# Set src/dest +if [[ "${operation}" == "unarchive" ]]; then + dest="${PWD}" + src="roms.archived" + +elif [[ "${operation}" == "archive" ]]; then + dest="roms.archived" + src="${PWD}" +else + echo "[ERROR] Invalid operation!" + exit 1 +fi + +# Move +roms_to_move=() +for rom in $(cat "${romlist}"); +do + echo "Adding rom from list: $rom to $dest" + rom_file=$(find "${src}" -name "${rom}.zip") + if [[ -z "${rom_file}" ]]; then + echo "[ERROR] Could not find rom ${rom}, skipping" + continue + fi + mv "${rom_file}" "${dest}" +done +