Skip to content

Instantly share code, notes, and snippets.

@its2loud
Created May 26, 2015 20:49
Show Gist options
  • Save its2loud/a0d5496be323307d771b to your computer and use it in GitHub Desktop.
Save its2loud/a0d5496be323307d771b to your computer and use it in GitHub Desktop.
NOW=$(date +"%y%m%d")
for f in "$@"
do
SPATH=${f%/*}"/"
FILENAME=${f##*/}
PREFIX=${FILENAME:0:6}
TRIM=${FILENAME:7}
case $PREFIX in
[0-9][0-9][0-1][0-9][0-3][0-9] )
DESTINATION=$SPATH$NOW"_"$TRIM
;;
*)
DESTINATION=$SPATH$NOW"_"$FILENAME
;;
esac
if [[ "$f" != "$DESTINATION" ]]; then mv "$f" "$DESTINATION"; fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment