Created
May 19, 2015 14:36
-
-
Save sathishvj/7586b3d51d39ab5b7201 to your computer and use it in GitHub Desktop.
Rename file or dir by appending current timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# move a file/folder to its name suffixed by the current timestamp | |
function mvdate() { | |
if [ ! -f "$1" -a ! -d "$1" ] | |
then | |
echo "Error! Given file/folder $1 does not exist! Exiting" | |
return 1 | |
fi | |
mv "$1" "$1_$(date +%Y%m%d%H%M%S)" | |
OUT=$? | |
if [ $OUT -ne 0 ]; then | |
echo "Error! renaming file." | |
fi | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment