加快文件定位和处理速度的脚本。
添加了,do.bat,fastdo.bat,lfastdo.bat三个文件。用来快速搜索并执行命令。
locate.bat
@echo
off
rem 快速文件定位,仿Linux locate程序
rem 作者:苏晓 2006年4月
rem 如下{}测试的写法是最好的!其他的会出错。
rem cls
if { %1 } == {} goto USEAGE
if { %1 } == { / ?} goto USEAGE
if / I { %1 } == { / update} goto UPDATE
if { %1 } == { / } goto TARGET
if / I { %1 } == { / del } goto TARGETDEL
if / I { %2 } == { / i} goto FINDEX
rem 开始判断'-'的包涵与否
echo %1 > restrict . sut
findstr / M / C: " - " restrict . sut > result . sut
for / F " tokens=1,2* " %%j in ( result . sut ) do if {%%j} == {restrict . sut} goto BAD
goto OK
:BAD
del result . sut
del restrict . sut
echo 请不要在字符串使用'-' , 而用 . 来代替。
goto END
:OK
del result . sut
del restrict . sut
:FIND
if exist %windir% dirdb . txt findstr %1 %windir% dirdb . txt
if not exist %windir% dirdb . txt echo 没有目录数据库,请先建立然后再搜索。
goto END
:FINDEX
if exist %windir% dirdb . txt findstr %2 %1 %windir% dirdb . txt
if not exist %windir% dirdb . txt echo 没有目录数据库,请先建立然后再搜索。
goto END
:UPDATE
echo 开始更新文件目录数据库。。。请等待
echo 这是locate程序使用的数据库文件 > %windir% dirdb . txt
echo 作者 :苏晓 2006年4月 >> %windir% dirdb . txt
for %%i in ( C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if exist %%i: echo 处理%%i盘 && echo true > %%i: Driver . true && if exist %%i: Driver . true pushd %%i: && del Driver . true && dir / a / s / b >> %windir% dirdb . txt && popd && echo %%i盘处理完毕
echo 数据库更新成功!
goto END
rem 部分目录更新
:TARGET
if { %2 } == {} goto USEAGE
if { %3 } == {} goto TARUPDATE
rem 开始判断'-'的包涵与否
echo %3 > restrict . sut
findstr / M / C: " - " restrict . sut > result . sut
for / F " tokens=1,2* " %%j in ( result . sut ) do if {%%j} == {restrict . sut} goto TARBAD
goto TAROK
:TARBAD
del result . sut
del restrict . sut
echo 请不要在字符串使用'-' , 而用 . 来代替。
goto END
:TAROK
del result . sut
del restrict . sut
if / I { %4 } == { / i} goto TARFINDEX
:TARFIND
if exist %2 dirdb . txt ( findstr %3 %2 dirdb . txt ) else ( echo 没有该目录数据库,请先建立然后再搜索。 )
goto END
:TARFINDEX
if exist %2 dirdb . txt ( findstr %4 %3 %2 dirdb . txt ) else ( echo 没有该目录数据库,请先建立然后再搜索。 )
goto END
:TARUPDATE
if not exist %2 goto NOPATH
echo 开始更新目标地址文件目录数据库。。。请等待
echo 这是locate程序使用的数据库文件 > %2 dirdb . txt
echo 作者 :苏晓 2006年4月 >> %2 dirdb . txt
for %%i in ( %2 ) do if exist %%i echo 处理%%i目录 && echo true > %%i Driver . true && if exist %%i Driver . true pushd %%i && del Driver . true && dir / a / s / b >> %2 dirdb . txt && popd && echo %%i处理完毕
goto END
:NOPATH
echo 目录不存在或者书写不正确。
goto END
:TARGETDEL
if { %2 } == {} goto USEAGE
if exist %2 dirdb . txt del %2 dirdb . txt
goto END
:USEAGE
echo 快速文件定位,仿Linux locate程序
echo 作者:苏晓 2006年4月
echo 使用方法:
echo %0 {[ / update] [[ / ][ / del ] [targetpath]] [filename [options: / I ,/ i]]}
echo / update 重新建立分区目录数据库dirdb . txt,在%windir%目录下
echo / 开启目标目录方式 targetpath是目标路径,结尾没有' '符号
echo / del 用来删除目标目录下的dirdb . txt文件
echo filename 要查找的文件名称可以是大概的 , 支持使用findstr通配符。
echo 目标目录方式下,不带filename则是新建立其目录数据库
echo options 可以是 / I ,/ i 表示忽略大小写
findstr / ?
echo 用法实例:
echo %0 " .rmvb$ .avi$ " 查找所有 . rmvb和 . avi结尾的文件
echo %0 " .rm[vb]*$ .avi$ " 查找所有 . rm和 . rmvb (. rmvvbb等等 ) 和 . avi结尾的文件
echo %0 / d: 建立d :下的数据库
echo %0 / d: soft 建立d: soft下的数据库
echo %0 / d: soft . exe $ / i 查找d: soft目录数据库中的记录 , 查找 . exe文件忽略大小写
echo %0 / del d: soft 删除d: soft目录数据库
:END
rem 快速文件定位,仿Linux locate程序
rem 作者:苏晓 2006年4月
rem 如下{}测试的写法是最好的!其他的会出错。
rem cls
if { %1 } == {} goto USEAGE
if { %1 } == { / ?} goto USEAGE
if / I { %1 } == { / update} goto UPDATE
if { %1 } == { / } goto TARGET
if / I { %1 } == { / del } goto TARGETDEL
if / I { %2 } == { / i} goto FINDEX
rem 开始判断'-'的包涵与否
echo %1 > restrict . sut
findstr / M / C: " - " restrict . sut > result . sut
for / F " tokens=1,2* " %%j in ( result . sut ) do if {%%j} == {restrict . sut} goto BAD
goto OK
:BAD
del result . sut
del restrict . sut
echo 请不要在字符串使用'-' , 而用 . 来代替。
goto END
:OK
del result . sut
del restrict . sut
:FIND
if exist %windir% dirdb . txt findstr %1 %windir% dirdb . txt
if not exist %windir% dirdb . txt echo 没有目录数据库,请先建立然后再搜索。
goto END
:FINDEX
if exist %windir% dirdb . txt findstr %2 %1 %windir% dirdb . txt
if not exist %windir% dirdb . txt echo 没有目录数据库,请先建立然后再搜索。
goto END
:UPDATE
echo 开始更新文件目录数据库。。。请等待
echo 这是locate程序使用的数据库文件 > %windir% dirdb . txt
echo 作者 :苏晓 2006年4月 >> %windir% dirdb . txt
for %%i in ( C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if exist %%i: echo 处理%%i盘 && echo true > %%i: Driver . true && if exist %%i: Driver . true pushd %%i: && del Driver . true && dir / a / s / b >> %windir% dirdb . txt && popd && echo %%i盘处理完毕
echo 数据库更新成功!
goto END
rem 部分目录更新
:TARGET
if { %2 } == {} goto USEAGE
if { %3 } == {} goto TARUPDATE
rem 开始判断'-'的包涵与否
echo %3 > restrict . sut
findstr / M / C: " - " restrict . sut > result . sut
for / F " tokens=1,2* " %%j in ( result . sut ) do if {%%j} == {restrict . sut} goto TARBAD
goto TAROK
:TARBAD
del result . sut
del restrict . sut
echo 请不要在字符串使用'-' , 而用 . 来代替。
goto END
:TAROK
del result . sut
del restrict . sut
if / I { %4 } == { / i} goto TARFINDEX
:TARFIND
if exist %2 dirdb . txt ( findstr %3 %2 dirdb . txt ) else ( echo 没有该目录数据库,请先建立然后再搜索。 )
goto END
:TARFINDEX
if exist %2 dirdb . txt ( findstr %4 %3 %2 dirdb . txt ) else ( echo 没有该目录数据库,请先建立然后再搜索。 )
goto END
:TARUPDATE
if not exist %2 goto NOPATH
echo 开始更新目标地址文件目录数据库。。。请等待
echo 这是locate程序使用的数据库文件 > %2 dirdb . txt
echo 作者 :苏晓 2006年4月 >> %2 dirdb . txt
for %%i in ( %2 ) do if exist %%i echo 处理%%i目录 && echo true > %%i Driver . true && if exist %%i Driver . true pushd %%i && del Driver . true && dir / a / s / b >> %2 dirdb . txt && popd && echo %%i处理完毕
goto END
:NOPATH
echo 目录不存在或者书写不正确。
goto END
:TARGETDEL
if { %2 } == {} goto USEAGE
if exist %2 dirdb . txt del %2 dirdb . txt
goto END
:USEAGE
echo 快速文件定位,仿Linux locate程序
echo 作者:苏晓 2006年4月
echo 使用方法:
echo %0 {[ / update] [[ / ][ / del ] [targetpath]] [filename [options: / I ,/ i]]}
echo / update 重新建立分区目录数据库dirdb . txt,在%windir%目录下
echo / 开启目标目录方式 targetpath是目标路径,结尾没有' '符号
echo / del 用来删除目标目录下的dirdb . txt文件
echo filename 要查找的文件名称可以是大概的 , 支持使用findstr通配符。
echo 目标目录方式下,不带filename则是新建立其目录数据库
echo options 可以是 / I ,/ i 表示忽略大小写
findstr / ?
echo 用法实例:
echo %0 " .rmvb$ .avi$ " 查找所有 . rmvb和 . avi结尾的文件
echo %0 " .rm[vb]*$ .avi$ " 查找所有 . rm和 . rmvb (. rmvvbb等等 ) 和 . avi结尾的文件
echo %0 / d: 建立d :下的数据库
echo %0 / d: soft 建立d: soft下的数据库
echo %0 / d: soft . exe $ / i 查找d: soft目录数据库中的记录 , 查找 . exe文件忽略大小写
echo %0 / del d: soft 删除d: soft目录数据库
:END
do.bat
@echo
off
rem 版本1.2
if { %1 } == {} goto useage
if { %1 } == { / ?} goto useage
if { %1 } == {--help} goto useage
if { %2 } == {} goto show
if { %2 } == { 0 } goto show
if { %2 } == { 1 } goto doone
if / I { %2 } == {all} goto alldo
if not exist %1 goto useage
if { %2 } == { 2 } goto truedo
set / a test = %2
if not %test% == 0 goto truedo
goto useage
rem 计数显示辅助
:counterReInit
set / a filecount = 0
goto TRUEOUT
:counterAdd
set / a filecount = %filecount% + 1
goto TRUEOUT
:counterAddShow
set / a filecount = %filecount% + 1
echo %filecount%?%~fzta1
goto TRUEOUT
rem 显示辅助结束
:truedo
:check
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAdd
set / a PASS = %2 - 1
set / a test = %PASS% / %filecount%
if %test% == 1 ( echo 索引超过了%filecount%! && goto EXIT )
for / F " skip=%PASS%tokens=* " %%i in ( %1 ) do set DOTHIS = %%i&& goto doit
:doone
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAdd
for / F " tokens=* " %%i in ( %1 ) do set DOTHIS = %%i&& goto doit
:alldo
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAdd
for / F " tokens=* " %%i in ( %1 ) do call %3 " %%i " %4 %5 %6 %7 %8 %9
goto EXIT
:doit
call %3 " %DOTHIS% " %4 %5 %6 %7 %8 %9
:EXIT
set DOTHIS =
set PASS =
del %1
goto EOF
:show
rem 仅仅type看不出条目改之
rem type %1
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAddShow " %%i "
goto EOF
:useage
echo locate定位程序之辅助执行程序。
echo 先locate搜索输出到文件 ( 列表文件 ), 再用本程序执行 .
echo do {列表文件名} {指定行数 ( 从1开始 , all表示对所有 :P慎用 ) } [调用程序 以及参数选项]
echo 如果省略第二个参数之后 ( 或为0 ) 则显示列表文件内容。
echo 如果有,调用程序。!只能!是将查找得到的文件作为 , 第!二!个参数。
:EOF
set test =
if exist re . txt goto clean
goto TRUEOUT
:clean
del re . txt
goto EOF
:TRUEOUT
rem 版本1.2
if { %1 } == {} goto useage
if { %1 } == { / ?} goto useage
if { %1 } == {--help} goto useage
if { %2 } == {} goto show
if { %2 } == { 0 } goto show
if { %2 } == { 1 } goto doone
if / I { %2 } == {all} goto alldo
if not exist %1 goto useage
if { %2 } == { 2 } goto truedo
set / a test = %2
if not %test% == 0 goto truedo
goto useage
rem 计数显示辅助
:counterReInit
set / a filecount = 0
goto TRUEOUT
:counterAdd
set / a filecount = %filecount% + 1
goto TRUEOUT
:counterAddShow
set / a filecount = %filecount% + 1
echo %filecount%?%~fzta1
goto TRUEOUT
rem 显示辅助结束
:truedo
:check
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAdd
set / a PASS = %2 - 1
set / a test = %PASS% / %filecount%
if %test% == 1 ( echo 索引超过了%filecount%! && goto EXIT )
for / F " skip=%PASS%tokens=* " %%i in ( %1 ) do set DOTHIS = %%i&& goto doit
:doone
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAdd
for / F " tokens=* " %%i in ( %1 ) do set DOTHIS = %%i&& goto doit
:alldo
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAdd
for / F " tokens=* " %%i in ( %1 ) do call %3 " %%i " %4 %5 %6 %7 %8 %9
goto EXIT
:doit
call %3 " %DOTHIS% " %4 %5 %6 %7 %8 %9
:EXIT
set DOTHIS =
set PASS =
del %1
goto EOF
:show
rem 仅仅type看不出条目改之
rem type %1
call :counterReInit
for / F " tokens=* " %%i in ( %1 ) do call :counterAddShow " %%i "
goto EOF
:useage
echo locate定位程序之辅助执行程序。
echo 先locate搜索输出到文件 ( 列表文件 ), 再用本程序执行 .
echo do {列表文件名} {指定行数 ( 从1开始 , all表示对所有 :P慎用 ) } [调用程序 以及参数选项]
echo 如果省略第二个参数之后 ( 或为0 ) 则显示列表文件内容。
echo 如果有,调用程序。!只能!是将查找得到的文件作为 , 第!二!个参数。
:EOF
set test =
if exist re . txt goto clean
goto TRUEOUT
:clean
del re . txt
goto EOF
:TRUEOUT
fastdo.bat
@echo
off
if { %1 } == {} goto use
if { %1 } == { / ?} goto use
if { %1 } == {--h} goto use
if { %1 } == { / } goto tar
if / I { %2 } == { / i} goto lit
call locate %1 > re . txt && call do re . txt %2 %3 %4 %5 %6 %7 %8 %9
goto EOF
:lit
call locate %1 %2 > re . txt && call do re . txt %3 %4 %5 %6 %7 %8 %9
goto EOF
:tar
if { %4 } == { / i} goto tarlit
call locate %1 %2 %3 > re . txt && call do re . txt %4 %5 %6 %7 %8 %9
goto EOF
:tarlit
call locate %1 %2 %3 %4 > re . txt && call do re . txt %5 %6 %7 %8 %9
goto EOF
:use
echo locate 以及 do 调用封装
echo 用于快速查找并且执行文件
echo 作者 :suxiaojack 2006.12
echo 使用方法:
echo fastdo {locate参数部分} [do参数部分]
echo 各部分参数详细情况参考该程序本身。
:EOF
if { %1 } == {} goto use
if { %1 } == { / ?} goto use
if { %1 } == {--h} goto use
if { %1 } == { / } goto tar
if / I { %2 } == { / i} goto lit
call locate %1 > re . txt && call do re . txt %2 %3 %4 %5 %6 %7 %8 %9
goto EOF
:lit
call locate %1 %2 > re . txt && call do re . txt %3 %4 %5 %6 %7 %8 %9
goto EOF
:tar
if { %4 } == { / i} goto tarlit
call locate %1 %2 %3 > re . txt && call do re . txt %4 %5 %6 %7 %8 %9
goto EOF
:tarlit
call locate %1 %2 %3 %4 > re . txt && call do re . txt %5 %6 %7 %8 %9
goto EOF
:use
echo locate 以及 do 调用封装
echo 用于快速查找并且执行文件
echo 作者 :suxiaojack 2006.12
echo 使用方法:
echo fastdo {locate参数部分} [do参数部分]
echo 各部分参数详细情况参考该程序本身。
:EOF
lfastdo.bat
@echo
off
rem local find for locate.bat
rem because 'locate / .' sometimes could be wrong typing.
if { %1 } == {} goto usage
if { %1 } == { / ?} goto useage
if { %1 } == {--help} goto useage
if { %1 } == { / update} goto update
if { %1 } == { / del } goto del
:find
rem 此处用fastdo即可
call fastdo / . %1 %2 %3 %4 %5 %6 %7 %8 %9
goto EOF
:usage
( echo suxiaojack writted in 2007.10 . 3
echo .
echo usage:
echo .
echo " %0 [/update|/del] | <mayfilename> [/i|/I] "
echo .
echo / update is locate / .
echo / del is locate / del .
echo other is locate / . mayfilename [option]
echo .)
goto EOF
:update
call locate / .
goto EOF
:del
call locate / del .
goto EOF
:EOF
rem local find for locate.bat
rem because 'locate / .' sometimes could be wrong typing.
if { %1 } == {} goto usage
if { %1 } == { / ?} goto useage
if { %1 } == {--help} goto useage
if { %1 } == { / update} goto update
if { %1 } == { / del } goto del
:find
rem 此处用fastdo即可
call fastdo / . %1 %2 %3 %4 %5 %6 %7 %8 %9
goto EOF
:usage
( echo suxiaojack writted in 2007.10 . 3
echo .
echo usage:
echo .
echo " %0 [/update|/del] | <mayfilename> [/i|/I] "
echo .
echo / update is locate / .
echo / del is locate / del .
echo other is locate / . mayfilename [option]
echo .)
goto EOF
:update
call locate / .
goto EOF
:del
call locate / del .
goto EOF
:EOF
采用fastdo somefile 1 notepad
就可以用notepad打开第一个查找到的文件,用all替换就能处理所有的文件.
lfastdo是对当前目录的数据库处理。
将4个脚本文件保存到windows目录下使用。