1.

Solve : assign variable name to file?

Answer»

Hi, i want create a simple text file with MD, i would like to assign a specific name, example:

MD testfile_041221.txt

041221 is the variable name for a current date

can you help me to run this?
Thank youAssuming that

Code: [SELECT]echo %date%
RETURNS Mi 2004-12-22
just extract the numbers like:

Code: [Select]set d=%date:~11,2%
set m=%date:~8,2%
set y=%date:~5,2%

and compose your file name:

Code: [Select]md testfile_%y%%m%%d%.txt
The representation of the date might be different on your PC, depends on your regional options.

Cheers,
[glb]cs[/glb]Hi, thanks for a reply!!!
I tried your solution but don't run nothing
Have a idea why?
SORRY for my question but is my first time to make a batch fileOK!!!!!!!!!!!!!!1
Thank you very MUCH!!!
I tried and retraied your solution and at the and I understended the operation, the code is:

echo %date%
set d=%date:~12,2%
set m=%date:~7,2%
set y=%date:~4,2%
copy con testfile_%y%%m%%d%.txt

I substitute MD with COPY CON for create a file but is not important because my file will be CREATED by wzzip.
Thanks a lot



Discussion

No Comment Found