Add Current Date and Time to File
How to add the current date and time to a file using three actions
This task will demonstrate how to add the current date and time to a file using the following actions:
1. Create Variable
2. Format Date Time
3. Rename File
First, a variable is created which will later hold the value of the current date and time.
Then, a "Format Date Time" action is used to convert a date and/or time into the specified format. On the "General" tab of this action, the format needs to be changed to one that can be included to a file (i.e. a format that doesn't include characters such as "/" or ":"). In this case, we will use m-d-yy_hh-nn-ss which is equivalent to month-day-year_hour-minute-seconds. After making changes, we will populate the variable named theDateTme with the results.
Last, the "Rename File" action is created to rename the file from the original name to the new name. For this example, we will rename C:\test.txt to the new name which includes the date and time after the original file name. In order to do this, simply add the variable %theDateTime% to the new file name (i.e. C:\test%theDateTime%.txt).
Note: In order for the task to work properly, please create a test.txt file in your c:\ drive or modify the file to be renamed in the "Rename File" action.