![]() |
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-07 06:38 |
48,040 topics / 350,125 posts / today 1 new / 48,252 members |
| DOS批处理 & 脚本技术(批处理室) » Help me take a look at this batch file |
| Printable Version 613 / 2 |
| Floor1 ak47b21b21 | Posted 2008-01-06 20:09 |
| 新手上路 Posts 4 Credits 11 | |
|
@echo off
set /p x=Please enter the filename, pay attention to case: for %%i in (C D E F ) do ( for /f %%a in ('dir %%i:\ /s/b^|find "%x%"') do ( set b=%%~ftza ) ) for /f "tokens=1-4" %%a in ("%b%") do ( set f=%%a set g=%%b set e=%%c set h=%%d ) echo The file has been found! echo File size is %e%KB echo File modification time is %f% %g% echo File path is %h%%x% pause>nul I wrote this myself. It's rather cumbersome, so I hope you experts will go easy on me. Right now there is one problem: when the path of the file you're searching for contains Chinese characters or spaces, it errors out... Can anyone help me solve this? |
|
| Floor2 fastslz | Posted 2008-01-06 20:21 |
| 铂金会员 Posts 2,315 Credits 5,493 From 上海 | |
| Floor3 junchen2 | Posted 2008-01-07 02:42 |
| 高级用户 Posts 219 Credits 537 From 杭州--半山 | |
|
@echo off
color 3f cls :1 title File Search Tool by-junchen2 date-2007-09-28 @echo n filename, wildcards can be used. @echo e file extension @echo p drive letter @echo o open mode: use s to open the found file, use a to open the folder containing the file del /q E:\findfile set /p var=n/e/p/o for /f "tokens=1-4 delims=/" %%a in ("%var%") do call :f "%%a" "%%b" "%%~sc" %%d :f if "%~1"=="" echo Missing parameter, please enter it again & goto :1 if "%~2"=="" echo Missing parameter, please enter it again & goto :1 if "%~3"=="" echo Missing parameter, please enter it again & goto :1 if "%~4"=="" echo Missing parameter, please enter it again & goto :1 cd\ cd /d %3 dir /b /s /a %~1.%~2>> e:\findfile\list.txt if errorlevel 1 goto :n for /f "delims=" %%d in (e:\findfile\list.txt) do echo %%~sd >>e:\findfile\s_list.txt @for /f "delims=" %%e in (e:\findfile\s_list.txt) do echo %%~dpe>>e:\findfile\sp_list.txt type e:\findfile\list.txt|findstr /n ".*" >>e:\findfile\n_list.txt type e:\findfile\s_list.txt|findstr /n ".*" >>e:\findfile\sn_list.txt type e:\findfile\sp_list.txt|findstr /n ".*" >>e:\findfile\spn_list.txt ::-----------^^^Add line numbers to the long/short filename lists and output to n_list.txt, sn_list.txt cls echo. echo %~1/%~2/%~3/%4 echo. findstr /a:a /n ".*" e:\findfile\list.txt :c set /p nub= Enter the line number to search: if %4 equ a goto :a if %4 equ s goto :s :a @for /f "tokens=1-3 delims=:" %%a in ('type e:\findfile\sn_list.txt') do echo %%a|findstr "\<%nub%" &&start %%b:%%c && goto :2 :s @for /f "tokens=1-3 delims=:" %%a in ('type e:\findfile\spn_list.txt') do echo %%a|findstr "\<%nub%" &&start %%b:%%c :2 set /p c=ind_other input=y if "%c%"=="y" echo. & goto :1 goto :c |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |