![]() |
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-12 12:01 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » Echo output of the del command |
| Printable Version 798 / 2 |
| Floor1 namelessone | Posted 2009-09-06 06:09 |
| 新手上路 Posts 6 Credits 7 | |
|
When executing the del delete command, if it succeeds there is no echo output at all; if it fails there will be prompts like file does not exist, etc.
Now I want a prompt after success so it can be distinguished from other cases. I tried the parameters of del and none of them can do it. Only the /s parameter gives a prompt when deleting a single file, but /s will recursively delete files with the same name in subdirectories, so it isn't safe. Are there any other delete commands that have this function? I wrote an echo %errorlevel% command that can show whether the deletion succeeded (actually using dir filename to see whether it still exists), but if I write it on separate lines in a bat it works, while if I write it on one line it may not work because of the & syntax. Please help me see what the problem is: Successful two-line script: Unsuccessful one-line script: |
|
| Floor2 523066680 | Posted 2009-09-06 06:15 |
| 银牌会员 Posts 1,133 Credits 2,362 | |
|
The so-called compound thing, because it's in the same statement~
This was discussed before, I forgot the reason. If it's on the same line, using enabled variable expansion !! should work And there's another way: [ Last edited by 523066680 on 2009-9-6 at 06:22 ] |
|
| Floor3 tireless | Posted 2009-09-06 07:27 |
| 银牌会员 Posts 1,122 Credits 2,025 | |
|
When should delayed expansion be used?
http://www.cn-dos.net/forum/viewthread.php?tid=20733 |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |