Created
January 13, 2019 17:27
-
-
Save TheYarin/f8c7528adfb8804593ee73634ae9ad76 to your computer and use it in GitHub Desktop.
Clear a folder when it is "created". For example, when a flash drive is connected and mounted to /path/to/containing/folder, clear the folder inside of it named FOLDER_NAME
This file contains hidden or 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
inotifywait -mq --format '%w%f/FOLDER_NAME/' --event=CREATE /path/to/containing/folder | while read DIR_TO_CLEAR | |
do | |
echo "$DIR_TO_CLEAR" | |
sleep 1 | |
find "$DIR_TO_CLEAR" -delete | |
mkdir -p "$DIR_TO_CLEAR" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment