中国DOS联盟论坛

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-09-26 00:17
47,813 topics / 349,918 posts / today 0 new / 48,275 members
DOS批处理 & 脚本技术(批处理室) » What's wrong with my findstr
Printable Version  3,268 / 22
Floor16 vkill Posted 2006-09-27 09:55
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
What exactly is the problem with the building's error? I saw that kind of error before.
Floor17 vkill Posted 2006-09-27 09:57
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Originally posted by namejm at 2006-9-27 09:53:


  From this code, it seems you are executing in the CMD window. Judging from your overall meaning, you want to first switch to the root directory of drive C and then create a folder, but the first sentence you started with didn't have...

Why do I get no errors when I execute it??? Confused
Floor18 pengfei Posted 2006-09-27 09:59
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
In fact, there are still bugs when the for is extended to file names:

In the for statement, when executing dir /ad or dir /a-d and using %%~ni to extend to the file name, the FOR statement processing mechanism may be to remove the "." after the last path "\" symbol and the following suffix, and only display the file name;

And if /ad only searches for folders, and there is no "." after the last path "/", it will display the entire last directory name.

[ Last edited by pengfei on 2006-9-27 at 12:10 ]
Floor19 pengfei Posted 2006-09-27 10:04
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
Originally posted by he200377 at 2006-9-27 09:57:

Why is there no error when I execute it??? puzzled


There is a flaw in the first command of your code. Suppose you run it on drive D...

But the expansion of %%~ni in the for statement does have a bug. I didn't test it at that time. Later I found that there was a problem with its expansion mechanism.

[ Last edited by pengfei on 2006-9-27 at 10:24 ]
Floor20 smileseeker Posted 2006-09-28 04:06
中级用户 Posts 83 Credits 316
Thanks to the enthusiastic help of all friends

The purpose of the younger brother is like this. Through the following code

echo.>temp.txt
for /f %%i in ('dir /ad /s /b') do (echo %%~ni|findstr "^*$" && echo %%i >>temp.txt)
for /f %%i in (temp.txt) do del /q %%i\*.*

Solve http://www.cn-dos.net/forum/viewthread.php?tid=23404&fpage=1

But it is stuck on findstr
Floor21 smileseeker Posted 2006-09-28 04:14
中级用户 Posts 83 Credits 316
Originally posted by namejm at 2006-9-27 09:44 AM:


This statement is incorrect. The 'dir' command under CMD can distinguish whether a file is a folder or a file. Otherwise, why are there the two parameters /ad and /a-d for the 'dir' command? If according to your understanding...



Agreed

D:\scripts>for /f %i in ("\123.456") do echo %~ni

D:\scripts>echo 123
123
Floor22 smileseeker Posted 2006-09-28 04:24
中级用户 Posts 83 Credits 316
This is a batch script I found on the forum before

set /p aa=Enter your code:
echo %aa% | findstr "^[a-z][A-Z]*$"||echo ERROR!!!
pause

I remember it seemed to be executable at that time. Now it's actually such an execution result

D:\scripts>set /p aa=Enter your code:
Enter your code:
D:\scripts>echo dfg | findstr "^[a-z][A-Z]*$" || echo ERROR!!!

D:\scripts>set /p aa=Enter your code:
Enter your code:
D:\scripts>echo dfg | findstr "^[a-z][A-Z]*$" || echo ERROR!!!

D:\scripts>set /p aa=Enter your code:
Enter your code:
D:\scripts>echo dfg | findstr "^[a-z][A-Z]*$" || echo ERROR!!!

D:\scripts>set /p aa=Enter your code:
Enter your code:
D:\scripts>echo dfg | findstr "^[a-z][A-Z]*$" || echo ERROR!!!

D:\scripts>set /p aa=Enter your code:
Enter your code:
D:\scripts>echo dfg | findstr "^[a-z][A-Z]*$" || echo ERROR!!!

D:\scripts>set /p aa=Enter your code:
Enter your code:
D:\scripts>echo dfg | findstr "^[a-z][A-Z]*$" || echo ERROR!!!

Speechless
Floor23 kgdetg1127 Posted 2007-10-11 21:25
初级用户 Posts 89 Credits 158
Prev  1 2
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023