1.

Solve : Hrm... escape sequence??

Answer»

I'm trying to write a batch file to created a folder on a BACKUP drive with the output of date /t as the folder name.

An example is "Wed 6/6/06" but I need to convert the / to dashes and possibly remove the wed to avoid 8.3 complications in dos batch files.

I have been trying to get the date /t output to a variable, as I can get it to a temp file but I don't understand how to read it into a variable. Then the next step would be manipulating the string and then using SOMETHING like mkdir %finalresult%.

Can you help me and point me in the right direction or resources to do this? thanks. :-?Code: [Select]@echo off
for /f "tokens=2-4 delims=/ " %%i in ('date /t') do (
set sysdate=%%k-%%i-%%j
)
md %sysdate%

8-)for /f "tokens=2" %%a in ('date/t') do set date=%%a

set date=%date:/=-%

md %date%

hope it helps
uliawesome, i did my own research prior to your replies and i stumbled on tokenizing and was just started to write my code. lol! Thanks a million for the help! At LEAST now I understand what my code is doing!

w00t!

- derekv6I would recommend against setting an environment variable to DATE. Sidewinder's example of SYSDATE is good, but if you use DATE you will overwrite the built-in DATE environment variable that Windows uses.
To avoid parsing the date /t you could do:
Code: [Select]md %date:~-7,2%-%date:~-10,2%-%date:~-4%
NOTE the code above uses the built-in DATE, so if you overwrote DATE already it won't come out right. The environment variables are contained within the current command processor, so all you have to do to reset DATE is close the CMD window, and open a new one.



Discussion

No Comment Found