欢迎您阅读本文,今天小编为你分享的电脑教程是:【DOS下的文本遍历和文件遍历代码】,下面是详细的讲解!
DOS下的文本遍历和文件遍历代码
:: VisitF.bat - 对指定路径指定文件进行遍历的程序
:: 第一参数为要遍历的文件(支持通配符),第二参数为要遍历的路径(缺省为C盘根)
@echo off
:main
if [%1]==[] if not exist filelist.txt goto end
:init
if exist filelist.txt if exist xset.asd goto loop
set file=%1
set base=%2
if [%2]==[] set base=c:
dir %base%\%file% /s /a /b > filelist.txt
echo e 100 ''set file='' > xset.asd
echo w >> xset.asd
echo q >> xset.asd
:loop
fc filelist.txt nul /n | find " 1:" > setfile.bat
if errorlevel 1 goto restore
debug setfile.bat nul
call setfile.bat
echo Visiting the file: %file%
:: User specified visit code replace this line
find "%file%" /v filelist.tx2
copy filelist.tx2 filelist.txt > nul
goto loop
:restore
if exist filelist.txt del filelist.txt
if exist xset.asd del xset.asd
if exist filelist.tx2 del filelist.tx2
if exist setfile.bat del setfile.bat
:end
关于DOS下的文本遍历和文件遍历代码的用户互动如下:
相关问题:dos实现在一个父文件夹里遍历找到名字为A的文件夹...
答:for /f "delims=" %%a in ('dir /ad/s/b A') do rd /s/q "%%~a" >>详细
相关问题:dos 遍历文件夹中的文件将他们复制到另一文件夹中
答:假设把A目录包括A目录中的子目录中的所有文件复制到B目录中,注:同名文件被覆盖。 for /f "delims=" %%a in ('dir /a-d/s/b A\*') do copy "%%~a" "B\" /y >>详细
相关问题:dos批处理命令遍历文件夹,删除文件夹下符合条件的...
答:@echo off setlocal enabledelayedexpansion pushd d:\test for /f %%i in ('dir/s/b old* abc*') do ( set fn=%%~ni set /a n=!fn:~3,2! if !n! gtr 12 del /f /q "%%i") >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
