Board logo

标题: 查找,获得完全路径,执行操作(针对文件及文件夹),求例子 [打印本页]

作者: su2353     时间: 2007-12-1 21:44    标题: 查找,获得完全路径,执行操作(针对文件及文件夹),求例子

相信论坛上有很多,但都不完整, 大家帮忙统合 还有我是入门级的,莫见笑

作者: junchen2     时间: 2007-12-1 22:27
@echo off color 3f cls :1 title 文件查找工具 by-junchen2 date-2007-09-28 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 参数缺少请再一次输入 & goto :1 if "%~2"=="" echo 参数缺少请再一次输入 & goto :1 if "%~3"=="" echo 参数缺少请再一次输入 & goto :1 if "%~4"=="" echo 参数缺少请再一次输入 & 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 ::-----------^^^将长短名文件列表加入行号输出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= 输入查找的行号 : 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

作者: su2353     时间: 2007-12-1 22:37
01.查找如 TEST 文件夹 和TEST.EXE 02.获得路径 03.操作

作者: junchen2     时间: 2007-12-1 23:25
n/e/p/o n 文件名,可以用通配符。 e 文件扩展名 p 盘符 o 打开方式 打开查找的文件就用s 打开文件所在的文件夹 就用 a 比如 想在 d 盘查找 test.exe 1 。 test/exe/d:/a 或者 2。 test/exe/d:/s [ Last edited by junchen2 on 2007-12-1 at 11:28 PM ]