Compare commits

..

2 Commits

Author SHA1 Message Date
oleg f391593857 progress 2024-07-19 11:04:30 -04:00
oleg 108ae35a06 progress 2024-07-19 10:45:46 -04:00
2 changed files with 20 additions and 11 deletions
+1 -1
View File
@@ -1 +1 @@
0.9.5 0.9.7
+19 -10
View File
@@ -3,14 +3,14 @@
Src=${1} Src=${1}
Days=${2} Days=${2}
if [ "${Src}" == "" ] if [ -z "$Days" ] || [ -z "$Src" ]; then
then echo "Usage: $0 <source_dir> <num_days>"
echo "Usage: $0 <source_dir> [<num_days>]"
exit 1 exit 1
fi fi
if [ "${Days}" == "" ]
then # Add / if Src does not have it (symlinks)
Days=30 if [ "${Src: -1}" != "/" ]; then
Src="${Src}/"
fi fi
declare -A Settings=() declare -A Settings=()
@@ -20,18 +20,27 @@ Settings[PruneDate]=$(date -d "${Days} days ago" '+%Y-%m-%d')
src=${Settings[Src]} src=${Settings[Src]}
prune_date=${Settings[PruneDate]} prune_date=${Settings[PruneDate]}
echo Before Pruning....
duf ${src}
echo "Finding files older than ${prune_date}..." echo "Finding files older than ${prune_date}..."
Cmd="find ${src} -type f ! -newermt \"${prune_date}\"" Cmd="find ${src} -type f ! -newermt \"${prune_date}\""
echo ${Cmd} echo ${Cmd}
files=($(eval ${Cmd})) files=($(eval ${Cmd}))
total_files=${#files[*]}
if [[ ${total_files} == 0 ]]
then
echo "No files found to be pruned. Bye..."
exit 0
fi
echo Before Pruning....
duf ${src}
echo "The following files will be removed:" echo "The following files will be removed:"
echo "====================================" echo "===================================="
for f in $files ; do echo $f; done for f in $files ; do ls -l $f; done
echo "====================================" echo "===================================="
echo "Total files to be pruned: ${#files[*]}" echo "Total files to be pruned: ${total_files}"
Cmd="${Cmd} -delete" Cmd="${Cmd} -delete"
echo ${Cmd} echo ${Cmd}