批处理生成 HTML格式 的文件列表
复制保存为 bat 即可
可修改 文件目录
不修改 默认生成当前路径下的文件列表
@echo off
title 生成文件列表 by 简爱
mode con: cols=30 lines=4
::
:: 生成 html 文件列表 转换文件大小为合适单位
:: 拿去修改 记得保留 简爱 名字
::
:: 设置目录 留空为当前
set dir=
set sj=%date:~0,4%-%date:~5,2%-%date:~8,2% %time:~0,2%:%time:~3,2%:%time:~6,2%
set file=文件列表_%dir%_%sj%.html
echo ^<!DOCTYPE html^>^<html^> >"%file%"
echo ^<meta charset=gb2312 /^>^<body bgcolor="#CCCCCC"^>^<div align="center"^>^<br/^> >>"%file%"
echo ^<h2^>文件列表 生成 by 简爱^</h2^>^<h4^>生成时间:%sj%^</h4^> >>"%file%"
echo ^<table width="95%%" border="1" align="center" cellpadding="5" cellspacing="0" style="font-family: 微软雅黑; color:#008000; font-size:14px;"^> >>"%file%"
echo ^<tr^>^<td width="40px"^>序号^</td^>^<td width="200px"^>文件名称^</td^>^<td width="135px"^>文件大小^</td^>^<td^>完整路径^</td^>^</tr^> >>"%file%"
setlocal enabledelayedexpansion
cls
echo;
echo 请稍后 ... ...
set n=
for /f "delims=" %%a in ('dir /s /b /a-d %dir%') do (
set /a n+=1
set /a z_size+=%%~za
call :size %%~za
echo ^<tr^>^<td^>!n!^</td^>^<td^>%%~nxa^</td^>^<td^>!size! ^(%%~za^)^</td^>^<td^>%%a^</td^>^</tr^> >>"%file%"
cls
echo;
echo 文件个数: !n!
echo 总大小: !z_size!
)
call :size !z_size!
del %temp%\js.vbs
echo ^</table^>^<h4^>文件总个数: !n! 个 ^ ^ ^ 文件总大小: %size% ^(!z_size! 字节^)^</h4^> >>"%file%"
echo ^<br/^>^<br/^>Powered by ^<a href="http://gouji.org" target="_blank"^>GouJi.org^</a^> ^ ^<a target="_blank" href="http://sighttp.qq.com/authd?IDKEY=83e9ce6969512c3981e5fcc63b2ebba0b92ec9494ace74b5"^>简爱^</a^>^<br/^>^<br/^>^</div^>^</body^>^</html^> >>"%file%"
cls
echo;
echo 生成完毕 按任意键打开
pause >nul
start "" "%file%"
exit
:size
if %1 geq 1073741824 (
call :js %1 1073741824 GB
goto :eof
)
if %1 geq 1048576 (
call :js %1 1048576 MB
goto :eof
)
if %1 geq 1024 (
call :js %1 1024 KB
goto :eof
)
set size=%1 Byte
goto :eof
:js
::除法保留小数 利用VBS 结果 为四舍五入
::速度慢 计算准确 好像不容易退出
if not exist %temp%\js.vbs (
echo wscript.echo round^(wscript.arguments^(0^)/wscript.arguments^(1^),2^) >%temp%\js.vbs
)
for /f %%a in ('cscript //nologo %temp%\js.vbs %1 %2') do set size=%%a %3
goto :eof本文出自简爱博客,转载时请注明出处及相应链接。

可以查询手机归属地
评论
非常不错!
非常不错!思路很好
好的评语
你好