Saving files with system date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help, i need to save a file from within a bat file
that allows me to add the system date to the file name
using the rename function.

Any help would be v much appreciated.
 
Please help, i need to save a file from within a bat file
that allows me to add the system date to the file name
using the rename function.

Any help would be v much appreciated.

OK, regulars: whose turn is it to answer the FAQ of all
FAQs this week?
 
Please help, i need to save a file from within a bat file
that allows me to add the system date to the file name
using the rename function.

Any help would be v much appreciated.

First you have to parse the date.
call univdate from tip 4835 in the 'Tips & Tricks' at http://www.jsiinc.com

The following will do the job if the file is to be renamed is
"test file.txt" in your My Documents folder:

@echo off
setlocal
call univdate
call :renameit "%UserProfile%\My Documents\test file.txt"
:: Continue your batch script
endlocal
goto :EOF
:renameit
ren %1 "%~N1_%yy%%mm%%dd%%~X1"

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top