Skip to content

Instantly share code, notes, and snippets.

@haruo31
Created October 6, 2019 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haruo31/807efc37faed2735fb4968ce3c07e961 to your computer and use it in GitHub Desktop.
Save haruo31/807efc37faed2735fb4968ce3c07e961 to your computer and use it in GitHub Desktop.
Find CD information and store into *.cdr image using diskutil information. (extra command xidel is required to work.)
diskutil list -plist |
xidel --data=- --extract "//*/string[.='CD_partition_scheme']/../*" |
awk 'NR % 2 == 1 { printf "%s\t", $0; } NR % 2 == 0 { print $0; }' |
IFS=$'\t' while read key value; do
case "$key" in
"DeviceIdentifier")
DEVICE=/dev/${value}
;;
"VolumeName")
VOLNAME="${value}"
;;
esac
hdiutil create -srcdevice ${DEVICE} -format UDTO -ov "${VOLNAME}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment