#!/bin/bash

# Description: Archive all non-empty files by renaming them with a
# timestamp appended to the original file name.  If multiple files are
# given, they all get the same timestamp.

# Synopsis: archive FILE1 [FILE2] [...]

suffix=$(date +%Y%m%d.%H%M%S)
for file in "$@"; do
    if [[ -e "$file" ]]; then
        if [[ $(stat -c'%s' "$file") -gt 0 ]]; then # file not empty?
            mv "$file"{,."$suffix"}
        fi
    fi
done
