-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|