Last active
December 12, 2020 02:02
-
-
Save frijole/fd8e939d73612f7d6ffe5fcaf14e2125 to your computer and use it in GitHub Desktop.
a shell script to copy the `Icons` folder out of an IconFactory archive DMG download, based on https://stackoverflow.com/a/48251635
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dmg_path="$1" | |
# use process redirection to capture the mount point and dev entry | |
IFS=$'\n' read -rd '\n' mount_point dev_entry < <( | |
# mount the diskimage; leave out -readonly if making changes to the filesystem | |
hdiutil attach -readonly -plist "$dmg_path" | \ | |
# convert output plist to json | |
plutil -convert json - -o - | \ | |
# extract mount point and dev entry | |
jq -r ' | |
.[] | .[] | | |
select(."volume-kind" == "hfs") | | |
."mount-point" + "\n" + ."dev-entry" | |
' | |
) | |
collection_name=${mount_point//\/Volumes\///} | |
echo "Copying $collection_name..." | |
cp -rp "$mount_point/Icons" "/Users/ian/Desktop/icons/$collection_name" | |
# unmount the disk image | |
hdiutil detach "$dev_entry" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I ran this on a whole pile of downloads via
$ for i in {1..57}; do ./dmgextract.sh ~/Downloads/download-$i.dmg; done
It choked on a couple of the downloads:
cp: /Volumes/Weyland Corp - Mac/Icons: No such file or directory
but its easy to catch any stragglers manually.