Computing.Net > Forums > Disk Operating System > how to concatenate 2 names ?

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to concatenate 2 names ?

Reply to Message Icon

Name: danicubos
Date: April 10, 2005 at 08:20:32 Pacific
OS: DOS
CPU/Ram: 256
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: April 10, 2005 at 09:08:17 Pacific
Reply:

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.


0

Response Number 2
Name: danicubos
Date: April 10, 2005 at 09:28:34 Pacific
Reply:

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 ...


0

Response Number 3
Name: Mechanix2Go
Date: April 10, 2005 at 09:50:31 Pacific
Reply:

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%.txt

Notice 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.


0

Response Number 4
Name: danicubos
Date: April 11, 2005 at 07:30:35 Pacific
Reply:

YES, IT WORKED SO GREAT !!!

It was i need ... OK

Thank u for your HELP


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: how to concatenate 2 names ?

How to delete and partiton a 2 gig hdd? www.computing.net/answers/dos/how-to-delete-and-partiton-a-2-gig-hdd/4931.html

How to Edit Registry in MS-DOS www.computing.net/answers/dos/how-to-edit-registry-in-msdos/2392.html

heres how to multi os www.computing.net/answers/dos/heres-how-to-multi-os/7010.html