Skip to content

Instantly share code, notes, and snippets.

@paultreny
Forked from ttscoff/customthumbs.sh
Created August 16, 2013 06:29
Show Gist options
  • Select an option

  • Save paultreny/6247743 to your computer and use it in GitHub Desktop.

Select an option

Save paultreny/6247743 to your computer and use it in GitHub Desktop.
#!/bin/bash
target=$1
filename=`basename $1`
image="${TMPDIR}${filename}.png"
rsrc="${TMPDIR}icn.rsrc"
# Create a thumbnail from the file preview
qlmanage -t -s 512 -o ${TMPDIR} $target
# apply the image to itself as an thumbnail icon
sips -i $image
# Extract the icon resource
DeRez -only icns $image > $rsrc
# Make the target accept a custom icon
SetFile -a C $target
# Apply the icon resource to the target
Rez -append $rsrc -o $target
# clean up
rm $rsrc $image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment