Skip to content

Instantly share code, notes, and snippets.

@typomedia typomedia/auto.extract.sh
Last active Mar 25, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.