BATCH script to save DATE to a variable (Users)
@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:
- BATCH script to save DATE to a variable - tauro, 01.03.2025, 04:19 (Users)
- BATCH script to save DATE to a variable - Rugxulo, 01.03.2025, 08:14
- BATCH script to save DATE to a variable - ecm, 01.03.2025, 12:15
- BATCH script to save DATE to a variable - marcov, 01.03.2025, 12:45
- BATCH script to save DATE to a variable - tauro, 02.03.2025, 02:16
- BATCH script to save DATE to a variable - Rugxulo, 02.03.2025, 03:26
- BATCH script to save DATE to a variable - RayeR, 25.03.2025, 05:44
- BATCH script to save DATE to a variable - rr, 25.03.2025, 18:41
- BATCH script to save DATE to a variable - Rugxulo, 01.03.2025, 18:43
- BATCH script to save DATE to a variable - rosegondon, 02.03.2025, 17:10
- BATCH script to save DATE to a variable - Rugxulo, 01.03.2025, 08:14