![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-02 05:44 |
48,037 topics / 350,122 posts / today 2 new / 48,250 members |
| DOS批处理 & 脚本技术(批处理室) » Help: Why can a statement that runs in cmd not work in a batch file? |
| Printable Version 1,641 / 9 |
| Floor1 xhf618 | Posted 2006-09-27 01:31 |
| 新手上路 Posts 4 Credits 12 | |
|
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. |
|
| Floor2 amao | Posted 2006-09-27 01:58 |
| 中级用户 Posts 152 Credits 316 | |
|
%a is represented by %%a instead.
|
|
| Floor3 electronixtar | Posted 2006-09-27 02:11 |
| 铂金会员 Posts 2,672 Credits 7,493 | |
|
Agree with the statement above.
|
|
| Floor4 xhf618 | Posted 2006-09-27 02:15 |
| 新手上路 Posts 4 Credits 12 | |
|
Still no good, it flashes by. The server is a 2003 system
|
|
| Floor5 xhf618 | Posted 2006-09-27 02:19 |
| 新手上路 Posts 4 Credits 12 | |
|
Oh, alright, sorry, I missed one, there are two %a's.
|
|
| Floor6 xhf618 | Posted 2006-09-27 02:20 |
| 新手上路 Posts 4 Credits 12 | |
|
Well, can it be made to automatically overwrite files with the same name?
|
|
| Floor7 NaturalJ0 | Posted 2006-09-27 04:03 |
| 银牌会员 Posts 533 Credits 1,181 | |
| Floor8 hymm2008 | Posted 2006-09-28 21:15 |
| 初级用户 Posts 43 Credits 102 | |
|
You can try using the Replace command
|
|
| Floor9 cxmzlxb | Posted 2006-10-02 21:29 |
| 新手上路 Posts 13 Credits 17 | |
| Floor10 qq82015930 | Posted 2006-10-13 07:18 |
| 中级用户 Posts 109 Credits 235 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |