Last active
March 25, 2016 21:01
-
-
Save typomedia/14dc651d7e00e1999536 to your computer and use it in GitHub Desktop.
Extract ZIP archives automatically after download
This file contains 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 | |
# 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