
CODE: [Copy to clipboard]@echo off
setlocal enabledelayedexpansion
for /f "skip=1 eol== tokens=1,2 delims=." %%i in (test.txt) do (
echo %%i|find "d:\dos">nul 2>nul && set new=%%i
echo f:\new\!new:~7!.%%j>>1.txt
)
del /q test.txt
ren 1.txt test.txt
start test.txt
CODE: [Copy to clipboard]上述代码保存为compare.bat,使用compare.bat %1 %2调用就可以了。@echo on
:: 比较目录1中存在,目录2中相应位置不存在的文件。
:: %1为目录1
:: %2为目录2
set a=%time%
if exist d:\f1.txt del d:\f1.txt /q
if exist d:\f2.txt del d:\f2.txt /q
dir %1\ /s /b > d:\f1.txt
type d:\f1.txt
cls
setlocal enabledelayedexpansion
for /f "eol== tokens=1 delims=/" %%i in (d:\f1.txt) do (
echo %%i|find "%1">nul 2>nul && (set new=%%i
set result=!new:%1=%2!
if not exist !result! (echo !result:%2=%1!>>d:\f2.txt)
)
)
@echo off
cls
echo.
set b=%time%
echo 您的比较结果放在d:\f3.txt中。
echo 开始时间:%a%
echo 结束时间:%b%
pause>nul
CODE: [Copy to clipboard]@echo off
set str=d:\dos\dos\
:: 字符串中不能出现引号
set num=0
:loop
set str=%str:~0,-1%
set /a num+=1
if not "%str%"=="" goto loop
echo 字符个数为 %num% 个
pause
| 欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) | Powered by Discuz! 2.5 |