grunt-date-suffix
Grunt plugin for renaming a file with a date suffix.
Install
npm install grunt-date-suffix --save-dev
Grunt configuration
datesuffix: rename1: /** * Original filename (with path if not in current directory) * @required */ file: "test.txt" /** * If move file to other directory, define here. * @optional */ dest: "outputDir" /** * Divider between filename and date. * @optional * @default "." */ divider: "-" /** * Switch behavior from "rename/move" to "copy". * @optional * @default false */ copy: true /** * Datetime format. Used node library `date-format`. * @optional * @default "yyyyMMddhhmmssSSS" */ date_format: "yyyyMMdd"
Configuration example
//Gruntfile.js grunt; grunt;
Use
grunt datesuffix:test1grunt datesuffix:test2grunt datesuffix:test3grunt datesuffix:test4grunt datesuffix:test5
Result
# test1 test.20150116201020123.txt # test2 output/test.20150116201020123.txt # test3 test.txt output/test.20150116.txt # test4 # no error is thrown even if the file does not exist # test5 test-20150116201020123.txt