![]() |
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 10:20 |
48,037 topics / 350,122 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » Ask for a batch script to delete files |
| Printable Version 2,834 / 27 |
| Floor16 redtek | Posted 2006-11-07 03:36 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
The effect of the delay variable you want:
The second method: The output is as follows: |
|
| Floor17 onlykier | Posted 2006-11-07 03:44 |
| 初级用户 Posts 23 Credits 50 | |
|
Brother upstairs, you are completely taking a shortcut.
In this way, I require: @echo %dbg% off for /L %%i in (0,1,4) do ( echo %%i ) echo %%i cannot be displayed using %%i. Another variable needs to be used for display, and there should be no relation at all between this variable and %%i |
|
| Floor18 redtek | Posted 2006-11-07 03:47 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Brother onlykier, I have read your code example on floor 8 and have run and debugged it many times...
However, the problem you were trying to address above didn't follow your line of thinking :) You thought about how to solve a problem, but almost all the places where errors occurred were affected by some basic knowledge points :) And Brother onlykier is learning very fast, but in the end, he still has to return to those basic variable assignments, SET, delay variables, For structures, operation and escape of special symbols... So, it is suggested that onlykier retype all the knowledge points mentioned in the following link line by line from start to finish ~:) Then come back and look again, I believe Brother onlykier will surpass the present... And this whole process may only take a few days or even one or two days. But doing this whole thing from start to finish in these one or two days, I believe onlykier will never have problems again, but will start to enter the state of knowing how to handle some unknown problems and can find solutions very quickly :) About SET variables, delay variables, usage of various symbols... http://www.cn-dos.net/forum/viewthread.php?tid=24549&fpage=1 [ Last edited by redtek on 2006-11-7 at 03:57 AM ] |
|
| Floor19 onlykier | Posted 2006-11-07 04:02 |
| 初级用户 Posts 23 Credits 50 | |
|
Brother upstairs, just kill me
I'll give another example I just want to display the first line, but the following code displays all, why? @echo off dir d: /b>>d:\1.txt set c=0 echo 1,%c% for /f %%i in (d:\1.txt) do ( if %c% equ 0 (set c=1 echo 2,%c% echo %%i) ) [ Last edited by onlykier on 2006-11-6 at 03:12 PM ] |
|
| Floor20 redtek | Posted 2006-11-07 04:10 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Brother upstairs, I won't kill you, or you let me commit suicide~:)
In your for %%i in (d:\1.txt) do (without adding the /f parameter here, can you read the file content?) |
|
| Floor21 onlykier | Posted 2006-11-07 04:12 |
| 初级用户 Posts 23 Credits 50 | |
|
I have made modifications. Brother upstairs, what's your QQ number? I'm so anxious waiting for the answer.
|
|
| Floor22 onlykier | Posted 2006-11-07 04:14 |
| 初级用户 Posts 23 Credits 50 | |
|
set c=1
echo 2,%c% Why is the output %c% still 0? |
|
| Floor23 onlykier | Posted 2006-11-07 04:28 |
| 初级用户 Posts 23 Credits 50 | |
|
Forum pagination, didn't see redtek's second method ^^!
set b=0 for /l %%i in (0,1,4) do ( echo !b! call set /a b+=1 And then ask, why is there a call here? |
|
| Floor24 redtek | Posted 2006-11-07 04:30 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
[ Last edited by redtek on 2006-11-7 at 04:36 AM ] |
|
| Floor25 lxmxn | Posted 2006-11-07 04:30 |
| 版主 Posts 4,938 Credits 11,386 | |
|
```
@echo off dir c:\ /b>>c:\1.txt set /p s=<c:\1.txt echo %s% pause ``` |
|
| Floor26 redtek | Posted 2006-11-07 04:31 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
Originally posted by onlykier at 2006-11-7 04:28: That call should be deleted, that was left over from another experiment when copying and forgetting to delete it~ : ) |
|
| Floor27 redtek | Posted 2006-11-07 04:32 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
Brother lxmxn's code is very concise, appreciate it~:)
|
|
| Floor28 onlykier | Posted 2006-11-07 04:48 |
| 初级用户 Posts 23 Credits 50 | |
|
@echo off
dir c:\ /b>>c:\1.txt set /p s=<c:\1.txt echo %s% pause Why does this code only display the first line? I thought it should display many lines because the content of c:\1.txt is assigned to s. |
|
| Prev 1 2 |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |