diff options
author | Nils <git@velohero.com> | 2016-11-06 22:01:57 +0100 |
---|---|---|
committer | Nils <git@velohero.com> | 2016-11-06 22:01:57 +0100 |
commit | 083f88808db0a7ea9f72ccd6e9c76cd19d9d6ca1 (patch) | |
tree | 617254aa2e24ef1fe2e4a81d5a068bb12f8fbef6 /gallery.sh | |
parent | 3e4f3efd92f5cf58fd38272704c10e8d28b03d7c (diff) |
use wc -c instead of ls -lah
Diffstat (limited to 'gallery.sh')
-rwxr-xr-x | gallery.sh | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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 <!DOCTYPE HTML> <html lang="en"> @@ -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 <a href="$filename" class="btn btn-primary" role="button">$movieicon $filename ($filesize)</a> 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 <a href="$filename" class="btn btn-primary" role="button">$movieicon $filename ($filesize)</a> EOF @@ -243,7 +243,7 @@ if [[ $(find . -type f -name \*.zip | wc -l) -gt 0 ]]; then <div class="col-xs-12"> 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 <a href="$filename" class="btn btn-primary" role="button">$downloadicon $filename ($filesize)</a> EOF |