1.

Solve : naming file name dynamicaly in dos?

Answer»

i need to assign a text file name into a variable in dos command. the text file name is created based on date. like 020809.txt Tomorrow the file name will be 030809.txt How can i assign this type of text file name into a variable in dos command?please correct me if i am wrong, but do you want to get the date from 1/23/45 to 12345?

if so(if your format is mm/dd/yyyy):
Code: [Select]@echo off
for /f "tokens=2-4 delims=/- " %%a in ('echo %date%') do SET dt=%%a%%b%%c
echo Todays date is %date% or %dt%
pause

Output:
Code: [Select]Todays date is Sat 08/01/2009 or 08012009
Press any key to continue . . .you tip has worked for me. thanks a lot. hope to keep in touch with you.your welcome, if you need any more computer help, just post a new thread.
@echo off
for /f "tokens=2-4 delims=/- " %a in ('echo %date%') do set dt=%b%a%c
copy E:\DATA\%dt%.txt E:\DATA\DD\FTA1.txt
exit

How can i use this dos command in a batch file?
Quote from: MMK on August 02, 2009, 04:14:36 AM

@echo off
for /f "tokens=2-4 delims=/- " %a in ('echo %date%') do set dt=%b%a%c
copy E:\DATA\%dt%.txt E:\DATA\DD\FTA1.txt
exit

How can i use this dos command in a batch file?

This isn't one DOS command, it is a group of them. They can be used in a batch file (.bat file). Paste the script into NOTEPAD (Notepad.exe) and save it as script.bat (but it could anything you want .bat), double-click the NEWLY created file and let it do it's thing.


Discussion

No Comment Found