added progress output

This commit is contained in:
Markus Ressel 2020-07-28 17:10:35 +02:00
parent dfdae73d76
commit 7004f91611

View File

@ -5,9 +5,15 @@ set -e
# exit on undeclared variable
set -u
current_index=0
function rebalance () {
file_path=$1
current_index="$((current_index + 1))"
progress_percent=$(echo "scale=2; $current_index*100/$file_count" | bc)
echo "Progress -- Files: $current_index/$file_count ($progress_percent%)"
tmp_extension=".balance"
echo "Copying '${file_path}' to '${file_path}${tmp_extension}'..."
@ -51,6 +57,11 @@ function rebalance () {
}
root_path=$1
# count files
file_count=$(find "$root_path" -type f | wc -l)
echo "Files to rebalance: $file_count"
# recursively scan through files and execute "rebalance" procedure
find "$root_path" -type f -print0 | while IFS= read -r -d '' file; do rebalance "$file"; done
echo ""