在我之前的question中,Aacini向我提供了此代码:
@echo on
setlocal EnableDelayedExpansion
set "digits=8"
set mypath=%~dp0
cd /d "%~dp0"
rem delete old list from current even if read only
del /f list.txt
rem Assemble the factor with the proper number of digits
set "factor=1"
for /L %%i in (1,1,%digits%) do set "factor=!factor!0"
rem Accumulate size of all extensions in 2 groups of %digits% digits each
for %%a in (*.*) do (
set "size=%factor%%%~Za"
set /A "low[%%~Xa]+=1!size:~-%digits%!-factor, carry=low[%%~Xa]/factor,
low[%%~Xa]%%=factor"
set "size=%%~Za"
set "size=!size:~0,-%digits%!"
set /A "high[%%~Xa]+=carry+size"
)
rem Show results
for /F "tokens=2,3 delims=[.]=" %%a in ('set high[') do (
if %%b neq 0 (
set "low=%factor%!low[.%%a]!"
echo %%a %%b!low:~-%digits%! bytes >>"%mypath%\list.txt"
) else (
echo %%a !low[.%%a]! bytes >>"%mypath%\list.txt"
)
)
现在我正在尝试在创建列表时搜索父目录。
我仍然希望将最终的测试文件保存到本地目录,所以没有更改!