Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

BATCH script to save DATE to a variable (Users)

posted by tauro E-mail, 01.03.2025, 04:19

@echo off
echo @echo off> current.bat
echo set date_=%%4>> current.bat
echo. | date | find.exe "Current" > go.bat
call go
if exist current.bat del current.bat
if exist go.bat del go.bat


I wrote this script after reading some of Timo Salmi's FAQs.

This saves the current date to the variable date_ so it can be used later.

But there's a few key things that I don't understand.

I discovered that the name of the first script "current.bat" must coincide with the term used with find.exe.
Otherwise the script doesn't work. Why is this so?

Why calling "go.bat" is correct? As far as I can understand that file is not supposed to be run, it's data to feed current.bat so that it can extract the desired field, %4, i.e. MM-DD-YYYY.

When does current.bat run and how does it get the information from go.bat?

What's trick here?

I'm open to all your suggestions and corrections. I'm here to learn.

 

Complete thread:

Back to the forum
Board view  Mix view
22397 Postings in 2076 Threads, 400 registered users, 107 users online (2 registered, 105 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum