![]() |
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-29 08:53 |
47,816 topics / 349,916 posts / today 0 new / 48,265 members |
| DOS批处理 & 脚本技术(批处理室) » Find Files and Operate (View Path, Copy, Delete).bat (9.5 Update) |
| Printable Version 7,954 / 23 |
| Floor1 vkill | Posted 2006-08-31 14:02 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
*.bat
Now there is still a problem, originating from for /f "tokens=* delims= " %%a in (%dati%_9.txt) do (find %dati%_6.txt /v /i "%%a">>%dati%_5.txt) In this sentence, there are several repetitions in the generated search file for the number of lines stored in the filtered file. How to fix this? Now I just want to restore the deletion and start over, making it more automated [ Last edited by he200377 on 2006-9-6 at 02:52 ] |
|
| Floor2 namejm | Posted 2006-08-31 14:55 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Not bad, relatively practical.
Of course, there are also flaws, and some may lead to very serious consequences: 1. For each variable set by set /p, the variable should be set to an empty value before receiving user input; otherwise, after returning to goto start next time, pressing a few Enter keys continuously will repeat the previous operation, which may cause loss of user data; 2. Once user input is to be received, there should be a few input error detection statements to detect more serious input errors to prevent accidents; 3. Always pay attention to the processing of strings with spaces; for example: copy %%i, the value of %%i may have spaces, and it will be wrong if not enclosed in quotes; in the sentence for "delims=," %%i in (a.txt), it seems that a sentence tokens=* should be added, and the %%i in del %%i should be enclosed in quotes with %%i... There are several similar places, please pay attention to modification; 4. During the execution process, there may be a long waiting time, so there should be a prompt on the screen, and irrelevant information should be cls'ed; If the building owner can improve it a little more, this script will be more useful. [ Last edited by namejm on 2006-8-31 at 15:00 ] |
|
| Floor3 vkill | Posted 2006-08-31 15:13 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
Thanks to the guidance from the person above.
Item 1: I really didn't think of this, this should be noted. Item 2: I think I should also block, | & and spaces, because I tried that as long as these characters are input in the input state, it will force to exit. This is because I was lazy and didn't add filtering. Oh. Item 3: Hmm, this modification is better. Item 4: I think the execution is very fast, about 2s, so I didn't write a prompt. Please help me modify it~ Hehe, thank you first. I'll see which places I didn't notice specifically. [ Last edited by he200377 on 2006-8-31 at 15:15 ] |
|
| Floor4 namejm | Posted 2006-08-31 17:14 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
Originally posted by he200377 at 2006-8-31 15:13: In fact, there are still a few places to modify: for example, the cmd /c in the second sentence is redundant; if you want to be overly critical, some can still be found. |
|
| Floor5 namejm | Posted 2006-08-31 17:22 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Here is the translated text:
Come with a modified version, only modified most of the problems mentioned earlier, and slightly modified the prompt statements that are easy to cause misunderstandings. The situation in the input error detection part needs to be improved, but there is no time to perfect it for the time being; when querying, what prompt information to add, the original poster can decide by themselves, so I won't add it; the original poster can compare the previous and subsequent codes and continue to modify where improvement is needed:
[ Last edited by namejm on 2006-8-31 at 17:27 ] |
|
| Floor6 vkill | Posted 2006-08-31 18:11 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
Thanks, I'll go back and take another look
|
|
| Floor7 vkill | Posted 2006-09-01 13:23 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
Make a mark
Because it uses call: label parameter Attachments 做恢复删除的时候想到的.rar (871 bytes) |
|
| Floor8 namejm | Posted 2006-09-01 17:17 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
Re he200377's top post:
The code you have now has a fatal error: The statement dir /a /s /b "%lj%" |find "%name%" >%dati%.txt cannot achieve the query, so I modified the relevant statement to achieve the intention of the exact match search you wanted: As for not searching the directory where the script file is located, I haven't thought of an efficient way for the time being. The alternative is to delete the records of the directory where the script file is located from the found results. There are still other small problems: For example, before each query, you need to clear the log content to avoid mixing with the previous results. |
|
| Floor9 namejm | Posted 2006-09-01 17:18 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
Originally posted by he200377 at 2006-9-1 13:23: I don't understand the intention of your posting this thread. Could you please explain it? |
|
| Floor10 vkill | Posted 2006-09-01 17:29 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
For example, before each query, you need to clear the log content to avoid mixing with the results of the previous time.
The file generated each time is named with the date + time (precise to seconds), so even if there is an interruption in the middle, it doesn't matter. In principle, the same - named file will not be generated. [ Last edited by he200377 on 2006 - 9 - 1 at 17:39 ] |
|
| Floor11 vkill | Posted 2006-09-01 17:31 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
Originally posted by namejm at 2006-9-1 17:18: Just thought of using it during testing and tried it out |
|
| Floor12 vkill | Posted 2006-09-01 17:39 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
|
Don't understand this? "%%~nxi" is the file name. Checked previous posts ~dp is the path, I think this is the file name.
//Tried it and understood [ Last edited by he200377 on 2006-9-1 at 17:48 ] |
|
| Floor13 namejm | Posted 2006-09-01 22:09 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
Originally posted by he200377 at 2006-9-1 17:29: You still missed a very important file: fc_name.txt. If you miss this file, it will be a big problem - if you query different files several times and then directly select delete, heh heh, just wait to cry nose吧:P |
|
| Floor14 namejm | Posted 2006-09-01 22:13 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
|
The function of searching for a specified file throughout the entire disk. I made one the other day, and I'll post it for you to refer to.
[ Last edited by namejm on 2006-9-1 at 23:08 ] |
|
| Floor15 vkill | Posted 2006-09-03 01:37 |
| 金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽 | |
Originally posted by namejm at 2006-9-1 22:13: |
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |