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-02 06:54
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Help: Why can a statement that runs in cmd not work in a batch file? View 1,642 Replies 9
Original Poster Posted 2006-09-27 01:31 ·  中国 广东 广州 电信
新手上路
Credits 12
Posts 4
Joined 2006-09-26 05:02
19-year member
UID 63685
Gender Male
Status Offline
The boss requires regularly backing up the design schemes of all computers in the design department to the server. I found this command available in a post:
for /r c:\ %a in (*.cdr) do @copy "%a" d:\

My approach is to first map the disk of each computer on the server, and then use the above command to search for cdr files and copy them to the server. But when I tested, I found that this statement can run in cmd, but when made into a batch file and run, it just flashes by and has no effect. Please help, thanks in advance.

In addition, when this command runs, can it add a function to automatically overwrite when encountering files with the same name? Because it needs to be backed up automatically every day, there will definitely be duplicates to overwrite. Thanks a lot for everyone's help.
Floor 2 Posted 2006-09-27 01:58 ·  美国 缅因州
中级用户
★★
Credits 316
Posts 152
Joined 2006-06-18 13:01
20-year member
UID 57204
Gender Male
Status Offline
%a is represented by %%a instead.
Floor 3 Posted 2006-09-27 02:11 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Agree with the statement above.

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 4 Posted 2006-09-27 02:15 ·  中国 广东 广州 电信
新手上路
Credits 12
Posts 4
Joined 2006-09-26 05:02
19-year member
UID 63685
Gender Male
Status Offline
Still no good, it flashes by. The server is a 2003 system
Floor 5 Posted 2006-09-27 02:19 ·  中国 广东 广州 电信
新手上路
Credits 12
Posts 4
Joined 2006-09-26 05:02
19-year member
UID 63685
Gender Male
Status Offline
Oh, alright, sorry, I missed one, there are two %a's.
Floor 6 Posted 2006-09-27 02:20 ·  中国 广东 广州 电信
新手上路
Credits 12
Posts 4
Joined 2006-09-26 05:02
19-year member
UID 63685
Gender Male
Status Offline
Well, can it be made to automatically overwrite files with the same name?
Floor 7 Posted 2006-09-27 04:03 ·  中国 江苏 苏州 电信
银牌会员
★★★
Credits 1,181
Posts 533
Joined 2006-08-14 12:54
19-year member
UID 60484
Status Offline
Floor 8 Posted 2006-09-28 21:15 ·  中国 广东 东莞 电信
初级用户
Credits 102
Posts 43
Joined 2006-09-07 05:22
19-year member
UID 62023
Status Offline
You can try using the Replace command
Floor 9 Posted 2006-10-02 21:29 ·  中国 广东 广州 番禺区 电信
新手上路
Credits 17
Posts 13
Joined 2006-09-06 13:27
19-year member
UID 61973
Status Offline
Floor 10 Posted 2006-10-13 07:18 ·  中国 重庆 璧山区 电信
中级用户
★★
Credits 235
Posts 109
Joined 2006-08-24 00:52
19-year member
UID 61161
Gender Male
Status Offline
Forum Jump: