Skip to content

Instantly share code, notes, and snippets.

@coffebar
Last active March 25, 2019 18:45
Show Gist options
  • Save coffebar/fbcc69a7be5cf58b32636d121fa58889 to your computer and use it in GitHub Desktop.
Save coffebar/fbcc69a7be5cf58b32636d121fa58889 to your computer and use it in GitHub Desktop.
Unpack the archives on the fly inside the directory of the script
#!/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