Skip to content

Instantly share code, notes, and snippets.

@frijole
Last active December 12, 2020 02:02
Show Gist options
  • Save frijole/fd8e939d73612f7d6ffe5fcaf14e2125 to your computer and use it in GitHub Desktop.
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
#!/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"
@frijole
Copy link
Author

frijole commented Dec 10, 2020

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.

before and after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment