From 083f88808db0a7ea9f72ccd6e9c76cd19d9d6ca1 Mon Sep 17 00:00:00 2001 From: Nils Date: Sun, 6 Nov 2016 22:01:57 +0100 Subject: use wc -c instead of ls -lah --- gallery.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gallery.sh b/gallery.sh index 1c100ac..2dfd560 100755 --- a/gallery.sh +++ b/gallery.sh @@ -138,7 +138,7 @@ while [[ $file -lt $numfiles ]]; do [[ $file -ne $((numfiles - 1)) ]] && next=${filelist[$((file + 1))]} imagehtmlfile=$thumbdir/$filename.html exifinfo=$($exif "$filename") - filesize=$(ls -lah "$filename" | awk '{ print $5}') + filesize=$(wc -c < "$filename" | awk '{$1/=1000000;printf "%.2fMB\n",$1}') cat > "$imagehtmlfile" << EOF @@ -214,7 +214,7 @@ if [[ $(find . -type f -name \*.mov -o -name '*.mp4' | wc -l) -gt 0 ]]; then EOF if [[ $(find . -type f -name \*.mov | wc -l) -gt 0 ]]; then for filename in *.[mM][oO][vV]; do - filesize=$(ls -lah "$filename" | awk '{ print $5}') + filesize=$(wc -c < "$filename" | awk '{$1/=1000000;printf "%.2fMB\n",$1}') cat >> "$htmlfile" << EOF $movieicon $filename ($filesize) EOF @@ -222,7 +222,7 @@ EOF fi if [[ $(find . -type f -name \*.mp4 | wc -l) -gt 0 ]]; then for filename in *.[mM][pP]4; do - filesize=$(ls -lah "$filename" | awk '{ print $5}') + filesize=$(wc -c < "$filename" | awk '{$1/=1000000;printf "%.2fMB\n",$1}') cat >> "$htmlfile" << EOF $movieicon $filename ($filesize) EOF @@ -243,7 +243,7 @@ if [[ $(find . -type f -name \*.zip | wc -l) -gt 0 ]]; then
EOF for filename in *.[zZ][iI][pP]; do - filesize=$(ls -lah "$filename" | awk '{ print $5}') + filesize=$(wc -c < "$filename" | awk '{$1/=1000000;printf "%.2fMB\n",$1}') cat >> "$htmlfile" << EOF $downloadicon $filename ($filesize) EOF -- cgit v1.2.3