zefie icon

iso2zip (cygwin windows)

zefie | PRO | 04/18/18 06:21:37 PM UTC | 0 ⭐ | 771 👁️ | Never ⏰ | []
Bash |

850 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
if [ ! -z "$1" ]; then
    path=$(readlink -f "$1")
    winpath=$(echo $path | sed -E "s/\/cygdrive\/([a-z])/\u\1\:/" | sed "s/\//\\\/g")
    echo Mounting $winpath
    powershell.exe "Mount-DiskImage \"$winpath\""
    isodrive=$(powershell.exe "Get-DiskImage \"$winpath\" | Get-Volume | Select-Object DriveLetter" | grep "\-\-\-" -A1 | tail -n1 | rev | cut -d' ' -f1 | rev | sed -E "s/\r//g")
    if [ ! -z $isodrive ]; then
        echo "Mounted on ${isodrive}:\\"
        cygpath=$(echo $isodrive | sed -E "s/([A-Z])/\/cygdrive\/\l\1/" | sed -E "s/\r//g")
        echo "Cygwin Path: $cygpath"
        zipfile=$(echo $path | rev | cut -d'.' -f2- | rev).zip
        echo "Output zip: $zipfile"
        cd "$cygpath"
        zip -9r "$zipfile" .
        echo "ZIP created, unmounting ISO"
        powershell.exe "Dismount-DiskImage \"$winpath\""
        exit 0;
    fi
    exit 1
else
    echo "Usage: $0 isofile"
    exit 1
fi

Comments