Skip to content

Commit

Permalink
handle any system
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeguzis committed Feb 28, 2024
1 parent 7551818 commit b0452af
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions utilities/move-mame-roms.sh → utilities/rom-migrator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,35 @@
# 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
system=$2
romlist=$3
archive="${HOME}/Emulation/roms/archive/${system}"

if [[ -z "${operation}" ]]; then
echo "[ERROR] Missing operation as arg 1! One of: archive, unarchive"
exit 1
fi
if [[ -z "${system}" ]]; then
echo "[ERROR] Missing system name as arg 2! E.g. 'mame', 'psp'"
exit 1
fi
if [[ -z "${romlist}" ]]; then
echo "[ERROR] Missing rom list to parse as arg 2!"
exit 1
fi
if [[ ! -d "${archive}" ]]; then
echo "[ERROR] Archive dir ${archive} does not exist!"
exit 1
fi

# Set src/dest
if [[ "${operation}" == "unarchive" ]]; then
dest="${PWD}"
src="roms.archived"
src="${archive}"

elif [[ "${operation}" == "archive" ]]; then
dest="roms.archived"
dest="${archive}"
src="${PWD}"
else
echo "[ERROR] Invalid operation!"
Expand All @@ -53,15 +62,21 @@ do
echo "[ERROR] Could not find ROM(s) ${rom}, skipping"
continue
fi

rom_file_no_ext=$(basename $(echo "${rom_file}" | sed 's/.zip//'))
chd_folder=$(find "${src}" -type d -name "${rom_file_no_ext}")

echo "Moving ROM from list: $rom to $dest"
mv "${rom_file}" "${dest}"
if [[ -n "${chd_folder}" ]]; then
echo "Moving ROM CHD folder/files from list: $chd_folder to $dest"
mv "${chd_folder}" "${dest}/"
##############################
# Special handling
##############################

# MAME
if [[ "${system}" == "mame" ]]; then
chd_folder=$(find "${src}" -type d -name "${rom_file_no_ext}")
echo "Moving ROM from list: $rom to $dest"
mv "${rom_file}" "${dest}"
if [[ -n "${chd_folder}" ]]; then
echo "Moving ROM CHD folder/files from list: $chd_folder to $dest"
mv "${chd_folder}" "${dest}/"
fi
fi
done

0 comments on commit b0452af

Please sign in to comment.