Categories
Welcome Center
Education & Development
Discussions
Certification Preparation
Recent Posts
Groups
Free Resources
Ebooks
Free Workshops
Trending Certifications Infographic
Infosec Training
IT & Security Training
Live Boot Camps
Security Awareness Training
About Infosec Institute
Home
Discussions
Off Topic
Date/Time in a batch file
Devilsbane
I'm writing a batch file, which I want to email to someone and have them run it. Once run, I want it to collect a bunch of information and save it to a file, and then copy that file to my computer.
One of the things I want is a date and time stamp at the bottom, but once the date command gets run, nothing else happens because the program is expecting me to enter a new date.
Is there another way around this, either a way to force the computer to skip that part or maybe a different command that gets me what I need?
Thanks
Find more posts tagged with
Save $250 on 2025 certification boot camps from Infosec!
Book now with code EOY2025
Button
Comments
Devilsbane
Nevermind, I can just use echo %date% and echo %time%
undomiel
date /t will get you the current date without asking to reset it.
%date% and %time% would probably be better to use though.
brad-
If it is acceptable, you could just rename the file with the datestamp:
copy c:\filename c:\filename_%date:~4,2%_%date:~7,2%_%date:~10,4%.txt
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
INFOSEC Boot Camps
$250
OFF
Use code
EOY2025
to receive $250 off your 2025 certification boot camp!
BROWSE BOOT CAMPS