zip2img
A small utility to converts ZIP archives to MS-DOS compatible disk images (virtual floppies) 💾️
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/bin/sh # _ _____ _ # (_) / __ (_) # _____ _ __ `' / /'_ _ __ ___ __ _ # |_ / | '_ \ / / | | '_ ` _ \ / _` | # / /| | |_) |./ /__| | | | | | | (_| | # /___|_| .__/ \_____/_|_| |_| |_|\__, | # | | __/ | # |_| |___/ # # Converts ZIP archives to MS-DOS compatible disk images (virtual floppies) # # Pablo (C) 2021 zip="$1" img="$2" dir="$(mktemp)" if [ -z "$zip" ] then echo 'zip2img zipfile [imagefile]' exit 0 fi # Generate the default filename for the output if it isn't set by the user if [ -z "$img" ] then fname="$(echo "$zip" | sed 's/\.[^.]*$//g')" fdir="$(dirname "$zip")" img="$fdir/$fname.img" fi # Extract the contents of the archive to a temporary directory unzip "$zip" -d "$dir/" # Create the disk image and copy the contents of the archive to it dd if=/dev/zero of="$img" count=1440 bs=1k /sbin/mkfs.msdos "$img" mcopy -i "$img" "$dir/"* ::/ # Delete the temporary directory rm "${dir:?}" -rf