Last active
March 25, 2019 18:45
-
-
Save coffebar/fbcc69a7be5cf58b32636d121fa58889 to your computer and use it in GitHub Desktop.
Unpack the archives on the fly inside the directory of the script
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 | |
cd "$(dirname "$0")" | |
inotifywait --format '%f' -m -e close_write -e moved_to "./" |\ | |
( | |
while read | |
do | |
FILE_TO_UNZIP=$(echo $REPLY | grep --only-matching --ignore-case -P "^.+\.(zip|rar|7z)$") | |
if [ "$FILE_TO_UNZIP" != "" ] | |
then | |
file-roller --extract-here "$REPLY" | |
fi | |
done | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment