Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
how to can i concatenate two file names ??
for example :
Today is : 10/04/2005 , so i have got this from
DATE /T command>>c:\log.txt
so : how can i set the date to variable and concatenate with the name ... for example
the final name may be log_10042005.txt
any idea ???
THANK U

Well,
If I understand the question, you want to rename the file and use the date as part of it, right?
Once you get the date into a variable, you can simply:
ren log.txt log_%DATE%.txt
BUT, if your date layout, which depends on language and regional setting, contains characters not allowed in file names, this WON'T work.
What version of DOS is this for?
M2
If at first you don't succeed, you're about average.

well
i want to do a backup logging, its the real reason for renaming with the date ...
it would be a batch for windows 2000 or windows NT, so, i understand, may be issues because that ... right ???
how can i get a short date format ?? (only the 01-04-05 for example) or what config do u recommend for REGIONAL SETTINGS and it really works ??
THANK U FOR QUICKLY RESPONDING ...

Hi,
Not sure about NT3 or NT4, but in w2k there is a built in DATE var. You can see the layout with:
echo %date%
Mine is:
Sun 10-04-2005
So if I want only dd-mm-yy, I can:
ren log.txt log_%date:~4,2%-%date:~7,2%-%date:~12,2%.txtNotice that this 'provides' the dash [-] as separator, avoiding the problem you'd get if your date layout included slash, backslash, colon etc.
If it was me, I'd make 'em:
MMDD.log
Short & sweet and easy to sort. And just put the whole year's logs somewhere like \2005logs\
M2
If at first you don't succeed, you're about average.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |