Advertisement
zefie

iso2zip (cygwin windows)

Apr 18th, 2018
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. #!/bin/bash
  2. if [ ! -z "$1" ]; then
  3.     path=$(readlink -f "$1")
  4.     winpath=$(echo $path | sed -E "s/\/cygdrive\/([a-z])/\u\1\:/" | sed "s/\//\\\/g")
  5.     echo Mounting $winpath
  6.     powershell.exe "Mount-DiskImage \"$winpath\""
  7.     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")
  8.     if [ ! -z $isodrive ]; then
  9.         echo "Mounted on ${isodrive}:\\"
  10.         cygpath=$(echo $isodrive | sed -E "s/([A-Z])/\/cygdrive\/\l\1/" | sed -E "s/\r//g")
  11.         echo "Cygwin Path: $cygpath"
  12.         zipfile=$(echo $path | rev | cut -d'.' -f2- | rev).zip
  13.         echo "Output zip: $zipfile"
  14.         cd "$cygpath"
  15.         zip -9r "$zipfile" .
  16.         echo "ZIP created, unmounting ISO"
  17.         powershell.exe "Dismount-DiskImage \"$winpath\""
  18.         exit 0;
  19.     fi
  20.     exit 1
  21. else
  22.     echo "Usage: $0 isofile"
  23.     exit 1
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement