Skip to content

Instantly share code, notes, and snippets.

@lambdan
Created July 5, 2026 20:08
Show Gist options
  • Select an option

  • Save lambdan/88fc4f4288f9480ed377b55a67451eaa to your computer and use it in GitHub Desktop.

Select an option

Save lambdan/88fc4f4288f9480ed377b55a67451eaa to your computer and use it in GitHub Desktop.
to_chd.sh
#!/bin/sh
set -e
INPUT="$1"
OUTPUT="${INPUT%.*}.chd"
if [ -z "$INPUT" ]; then
echo "Usage: $0 <input.iso>"
exit 1
fi
if [ ! -f "$INPUT" ]; then
echo "Input file not found: $INPUT"
exit 1
fi
if [ -f "$OUTPUT" ]; then
echo "Output file already exists: $OUTPUT"
exit 1
fi
chdman createcd -i "$INPUT" -o "$OUTPUT"
echo
echo "ISO size: $(du -h "$INPUT" | cut -f1)"
echo "CHD size: $(du -h "$OUTPUT" | cut -f1)"
echo
read -p "Delete original ISO? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm "$INPUT"
echo "Original ISO deleted."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment