Hoy tuve que convertir un par de imágenes .dmg a .iso, para poder leerlas desde Window$ y poder quemarlas. Para ello me armé un pequeño script que automatiza la tarea sin la necesidad de usar un programa con interfaz gráfica.
#!/usr/bin/env bash
PROGNAME=`basename "$0"`
HDIUTIL=`which hdiutil`
SRC=$1
DST=$2
# Functions
read_var()
{
if [ "X$2" != "X" ]; then
read -p "$1 (default: $2): " var
else
read -p "$1: " var
fi
if [ -z "$var" ]; then echo $2; else echo $var; fi
}
if [ "X$HDIUTIL" == "X" ]; then
echo "ERROR: hdiutil command not found."
exit 1
fi
if [ "X$SRC" == "X" ]; then
echo "USAGE: $PROGNAME <src> <dst>"
exit 1
fi
if [ "X$DST" == "X" ]; then
DST=`echo "$SRC" | sed -e 's/\.[dD][mM][gG]$/\.iso/g'`
fi
if [ ! -f $SRC ]; then
echo "ERROR: $SRC does not exists."
exit 1
fi
if [ -f $DST ]; then
OVER=`read_var "ERROR: $DST already exists. Overwrite?" "n" | tr [:upper:] [:lower:]`
if [ "X$OVER" != "Xy" ]; then
exit 1
fi
fi
$HDIUTIL convert "$SRC" -format UDTO -o "$DST"
if [ -f "$DST.cdr" ]; then
mv "$DST.cdr" "$DST"
fi
exit 0
PD: Esto funciona en Mac OS X únicamente, pero calculo que se puede hacer un equivalente con el comando “dd” de Linux.
Links relacionados: