included shred option for rm-progress
This commit is contained in:
@@ -4,18 +4,21 @@ set -e
|
||||
function helpexit() {
|
||||
echo Delete files with a progress bar.
|
||||
echo This command is always recursive to folders!
|
||||
echo '-f Dont ask questions'
|
||||
echo '--nc Dont count files first'
|
||||
echo '-f Do not ask questions'
|
||||
echo '--nc Do not count files first'
|
||||
echo '--shred Use "shred -u" instead of rm'
|
||||
exit
|
||||
}
|
||||
|
||||
FORCE=0
|
||||
RMCOMMAND=rm
|
||||
FOLDERS=( )
|
||||
for ((i=1; i<=${#@}; i++)) {
|
||||
[[ "${!i}" = "-h" ]] && helpexit
|
||||
[[ "${!i}" = "--help" ]] && helpexit
|
||||
[[ "${!i}" = "-f" ]] && { FORCE=1; RMFORCE="-f"; continue; }
|
||||
[[ "${!i}" = "--nc" ]] && { NOCOUNT=1; continue; }
|
||||
[[ "${!i}" = "--shred" ]] && { RMCOMMAND="shred -u"; continue; }
|
||||
[[ "${!i}" = "-"* ]] && helpexit
|
||||
FOLDERS+=( "${!i%/}" )
|
||||
}
|
||||
@@ -35,7 +38,7 @@ function deletefiles() {
|
||||
[[ $files -ne 0 ]] && percent=$((200*$i/$files % 2 + 100*$i/$files))
|
||||
printf "\r%02d:%02d:%02d %6d/%d %3d%% %s\033[0K" \
|
||||
$(($SECONDS/3600)) $(($SECONDS%3600/60)) $(($SECONDS%60)) $i $files "$percent" "$line"
|
||||
rm "$line"
|
||||
$RMCOMMAND $RMFORCE "$line"
|
||||
done < <(find "$@" \( -type f -or -type l \) -print0)
|
||||
printf "\n"
|
||||
}
|
||||
@@ -53,7 +56,7 @@ function deletefolders() {
|
||||
[[ $folders -ne 0 ]] && percent=$((200*$i/$folders % 2 + 100*$i/$folders))
|
||||
printf "\r%02d:%02d:%02d %6d/%d %3d%% %s\033[0K" \
|
||||
$(($SECONDS/3600)) $(($SECONDS%3600/60)) $(($SECONDS%60)) $i $folders "$percent" "$line"
|
||||
rm -r "$line"
|
||||
rm $RMFORCE -r "$line"
|
||||
done < <(find "$@" -depth -type d -print0)
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user