Skip to content

Commit

Permalink
Add mame export/import
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeguzis committed Feb 27, 2024
1 parent 5917ded commit f938ce9
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions utilities/move-mame-roms.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f938ce9

Please sign in to comment.