General Question

XOIIO's avatar

How can I get a batch file to type the current time/date to a text file?

Asked by XOIIO (18243points) September 19th, 2010

I know you use “TYPE example >filename” to add or place text into a filename, but hoe can I get it to put a variable in.

I’ve tried “TYPE %TIME% >filename” but it always messes up.

I also need it to use any variable I want it to use text from any vaiable such as
“set /p note=
if ’%note%’==‘2’ GOTO b
if ’%note%’==‘1’ GOTO a”

and put the text from the user input into a text file.

Also if you know of a command to display all the text froma certain text file that would be great. Thanks.

Observing members: 0 Composing members: 0

6 Answers

CyanoticWasp's avatar

Check out AutoHotKey and you’ll be amazed at what you can do that’s even better than batch files. And simpler, too.

ratboy's avatar

This page should tell you everything you want to know.

XOIIO's avatar

@cyanoticwasp I want to use batch only so it will work on various oses.

@ratboy thatks, I’ll take a peek at that.

IchtheosaurusRex's avatar

Try this:


XOIIO's avatar

@IchtheosaurusRex Thanks! I was having trouble figuring it out.

Do you know a command that will pull the text from the file and display it?

IchtheosaurusRex's avatar

@XOIIO , if it’s a text file you just enter


and it will be dumped on the console.

But if you enter


by itself, it displays the date on the console.

Answer this question




to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
Knowledge Networking @ Fluther