Skip to content

Instantly share code, notes, and snippets.

@typomedia
Last active March 25, 2016 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typomedia/14dc651d7e00e1999536 to your computer and use it in GitHub Desktop.
Save typomedia/14dc651d7e00e1999536 to your computer and use it in GitHub Desktop.
Extract ZIP archives automatically after download
#!/bin/bash
# Copyright 2016 Typomedia Foundation. All rights reserved.
# Released under GPL version 3.
#
# Inotify Auto Extract v1.0
watchdir=$HOME/Downloads
# run on specific events and return the filename only
inotifywait -q -m -e modify -e moved_to -e create --format '%f' $watchdir | while read FILE
do
# only if mime type is zip
if [ $(mimetype -b $FILE) == "application/zip" ]
then
unzip -o "${watchdir}/${FILE}" -d $watchdir
rm -f "${watchdir}/${FILE}"
sleep 10
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment