1.

Solve : Need help with variables...?

Answer»

I have an executable that returns the CURRENT date in yymmdd format. I have a need to automate the daily creation of a folder with this name, and move or copy files that are being overwritten nightly into this new folder. I thought if I ran this executable and redirected the output to a "date.dat" file, that I COULD use a batch file to type this value to a variable, then use a command like

md %1

to create the folder. Doesn't work, no matter how I try it. Any thoughts?Right idea, wrong variable name. Variables %1 thru %9 are INPUT variables to a process. Data returned by a process can be handled by a FOR statement.

Code: [Select]
for /f %%a in (date.dat) do (set yymmdd=%%a)
md %yymmdd%


You can use %yymmdd% anywhere you need to for your directory name.

The code only WORKS provided the date is the only data in the date.dat file. Type for /? at the command line for details on how to skip lines and otherwise process date.dat

Hope this helps. You most definitely do one thing at a time well. I also see more usage from this "for" command, and I THANK you very much



Discussion

No Comment Found