From 3deac3cb0f7c86863b58ec9ea08fa225da01126d Mon Sep 17 00:00:00 2001 From: Emily Frost Date: Mon, 11 Feb 2019 13:05:22 -0600 Subject: [PATCH] Added ps2-disc-rename. --- ps2-disc-rename | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 ps2-disc-rename diff --git a/ps2-disc-rename b/ps2-disc-rename new file mode 100755 index 0000000..2bcce0e --- /dev/null +++ b/ps2-disc-rename @@ -0,0 +1,23 @@ +#!/bin/bash +# A simple tool to prepend PS2 disc image file names with their appropriate gameids. +# This is just for OpenPS2Loader, and requires hdl-dump. + +for disc_name in "$@"; do + disc_path="$(realpath "$disc_name")" + disc_dir="$(dirname "$disc_path")" + disc_short="$(basename "$disc_path")" + + hdldump_output="$(hdl-dump cdvd_info "$disc_path" | cut -d ' ' -f 1)" + gameid="${hdldump_output//\"/}" + + if ! echo "$disc_path" | grep -q "$gameid"; then + new_disc_filename="${gameid}.${disc_short}" + new_disc_path="${disc_dir}/${new_disc_filename}" + + echo "Previous path: ${disc_path}" + echo "New path: ${new_disc_path}" + mv "$disc_path" "$new_disc_path" + else + echo "${disc_short} is already named correctly." + fi +done