Skip to content

Instantly share code, notes, and snippets.

@blurymind
Last active June 13, 2022 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blurymind/2888fcd8bce1f723d2f626a4e9790b9a to your computer and use it in GitHub Desktop.
Save blurymind/2888fcd8bce1f723d2f626a4e9790b9a to your computer and use it in GitHub Desktop.
deleteSmallSizeSubFolders.sh
#!/bin/sh
# fix for folders/files with spaces in them (ln13)
OLDIFS=$IFS
IFS=$'\n'
# thunar folder custom action /home/fox/INSTALL/deleteSmallSizeSubFolders.sh %F
# %F is full path to all selected folders
for var in "$@"
do
find "$var" -mindepth 1 -maxdepth 1 -type d -exec du -ks {} + | awk '$1 <= 50' | cut -f 2- | xclip -sel clip
for j in $(xclip -selection c -o)
do
zenity --question --title="Confirm" --text="This folder is likely empty:\n $j\n\nDelete it?"
case $? in
0)
rm -r "$j"
zenity --notification --text "Deleted\n$j"
;;
1)
#cancel
;;
esac
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment