假设变量:A=D:\backup\dos\fdisk.exe ,请问如何才能在减去后面的fdisk.xe,只取前面的一部份呢?(变量 A 是搜索文件后赋于的值,不清楚具体的长度,只能知道后面的文件名。)
求那位大侠知道的,请帮帮小弟!急!
谢谢!!
求那位大侠知道的,请帮帮小弟!急!
谢谢!!
联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!
@echo off
if not %pass%!==! goto %pass%
set pass=pass2
set count=!!
set flag=
set pattern=
set realdir=
set testdir=
set olddircmd=%dircmd%
set dircmd=
set a=
set ostype=DOS
if %OS%!==Windows_NT! set ostype=NT
set null=nul
if %ostype%==NT set null=
:loop0
set pattern=%pattern%%1
if %2!==! goto cont0
set pattern=%pattern%
shift
set flag="
goto loop0
:cont0
if not exist %flag%%pattern%%null%%flag% goto error
echo %pattern%> }1{.dat
dir %flag%%pattern%*.*%flag% /a:d | find "Volume in drive" > }2{.bat
echo set !=%%3> volume.bat
call }2{
set !=%!%:\
set realdir=%!%
uterloop
dir %flag%%realdir%*.*%flag% /a:d /b > }3{.dat
echo.>> }3{.dat
date < }3{.dat | find "En" > }4{.dat
echo exit>> }4{.dat
command /e:1024 < }4{.dat >> nul
call }5{.bat
echo %realdir%> }6{.dat
find /i "%pattern%" }6{.dat > nul
if not errorlevel 1 goto display
set count=%count%!
goto outerloop
:pass2
if %ostype%==NT goto nt1
if %4!==! goto end
goto cont11
:nt1
if %5!==! goto end
:cont11
set a=%realdir%
set testdir=
:innerloop
if %ostype%==DOS set a=%a%%4
if %ostype%==NT set a=%a%%5
if %ostype%==DOS set testdir=%testdir%%4
if %ostype%==NT set testdir=%testdir%%5
shift
if %ostype%==NT goto nt2
if %4!==! goto cont1
goto cont12
:nt2
if %5!==! goto cont1
:cont12
set a=%a%
set testdir=%testdir%
goto innerloop
:cont1
set a=%a%\
find /i "%a%" }1{.dat > nul
if errorlevel 1 goto end
echo set %count%=%testdir%> }5{.bat
echo set realdir=%a%>> }5{.bat
goto end
:display
:cleanup
set dircmd=%olddircmd%
set maxcount=%count%
set count=!
echo The elements in %pattern% are
:cleancountloop
set %count%=
if %count%==%maxcount% goto cleancont
set count=%count%!
echo echo %%%count%%%>}5{.bat
call }5{
set %count%=
goto cleancountloop
:cleancont
set pass=
set ostype=
set count=
set maxcount=
set pattern=
set realdir=
set testdir=
set a=
set flag=
set olddircmd=
del }?{.dat
goto end
:error
echo.
echo.
echo ERROR Report: %pattern%
echo does not exist, lacks a trailing '\' or has some other error.
:end
@echo off
dir %A% | find " Directory of ">_setdir.bat
echo set abase=%%2>Directory.bat
call _setdir.bat
del _setdir.bat
del Directory.bat