China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 18:44
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Please come in and take a look, why can't this string be concatenated? View 1,639 Replies 3
Original Poster Posted 2009-11-24 12:40 ·  中国 重庆 电信
初级用户
Credits 36
Posts 17
Joined 2009-11-07 16:50
16-year member
UID 154358
Gender Female
Status Offline
The batch file I wrote is as follows:

@echo off
set a=h
for /d %%f in ("c:\documents and settings\*") do set a=%%f\Cookies &@echo %a%

What I originally meant was to turn a into a string like c:\documents and settings\username\Cookies, but when I print it with the above command, the value of environment variable a still has not changed and is still the initial value h.
Question for all you experts, how exactly should this batch file be written?
Floor 2 Posted 2009-11-25 00:17 ·  中国 北京 朝阳区 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Take a look at tutorials related to environment variables.

有问题请发论坛或者自行搜索,再短消息问我的统统是SB
Floor 3 Posted 2009-11-26 03:18 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Just change echo %a% to “call echo %%a%%”.

You can also do it with delayed variable expansion; there are lots of tutorials on the forum, search for them.
Floor 4 Posted 2009-11-27 14:20 ·  中国 重庆 电信
初级用户
Credits 36
Posts 17
Joined 2009-11-07 16:50
16-year member
UID 154358
Gender Female
Status Offline
Many thanks, moderator, I understand now
Forum Jump: