Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Microsoft
Showing results for 
Search instead for 
Did you mean: 

Add date and time to a file name

Frequent Advisor

Add date and time to a file name

Could someone please let me know how I can add the date and time to a file name so that it makes it unique...easy in unix but do not seem to be able to do it in Windows.
I already have a vbs that adds the date but I now also need the time.
I include the script that may help someone that knows this well to just add the missing 'bits'.




P.S. This thread has been moved from Archived Desktops and Workstations Boards > Windows based to Microsoft > general. - Hp forum moderator

Pat Flanagan
Honored Contributor

Re: Add date and time to a file name


I'm certain that this has come up in the forums before, about a year ago or so.

Go to the Forums advanced search link at the top of this page, and search in both ITRC and Business Support forums.

Frequent Advisor

Re: Add date and time to a file name


Thanks for your reply..I appreciate it. I had a quick look but could not find anything but I will have a more thorough look later on using various criteria in the search.
thanks kyris
Frequent Advisor

Re: Add date and time to a file name

Perhaps there is a simpler way but here it is adding the date to a file name - set in a batch file...

set YYYYMMDD=%DATE:~10,4%%DATE:~7,2%%DATE:~4,2%

type c:\reports\myreport.txt >> c:\reports\myreport_%YYYYMMDD%.txt