Skip to content

Instantly share code, notes, and snippets.

@cornfeedhobo
Last active August 30, 2025 14:42
Show Gist options
  • Save cornfeedhobo/3a1c03b46e41043111ff094b24856dc5 to your computer and use it in GitHub Desktop.
Save cornfeedhobo/3a1c03b46e41043111ff094b24856dc5 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
if [[ $# -eq 0 ]]; then
echo "Usage: $0 <path/to/zip ...> "
exit 1
fi
for zip_file in "${@}"; do
echo "${zip_file}"
done
read -r -p "Do you want to continue? (y/n): " choice
case "$choice" in
y|Y|yes|YES) ;;
*) exit 0 ;;
esac
dst_dir="$(pwd)"
for zip_file in "${@}"; do
if [[ ! "${zip_file}" == *.zip ]] || [[ ! -f "${zip_file}" ]]; then
echo "SKIPPING: ${zip_file} is not a zip archive"
continue
fi
src_dir="$(dirname "${zip_file}")"
zip_name="$(basename "${zip_file}")"
game_name="${zip_name%.zip}"
if [[ -f "${dst_dir}/${game_name}.chd" ]]; then
echo "SKIPPING: ${game_name}.chd already exists"
continue
fi
cd "${src_dir}"
unzip "${zip_name}" -d "${game_name}"
cd "${game_name}"
chdman createcd -i "${game_name}.cue" -o "${dst_dir}/${game_name}.chd"
cd "${src_dir}"
rm -rf "${game_name}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment