使用bat批处理显示当前文件夹目录下文件列表

使用bat批处理显示当前文件夹目录下文件列表

 

代码如下:

@echo off
setlocal
set LISTFILE=list.html
echo MAKING LISTFILE … (PLEASE WAIT)
echo ^<!doctype html^>         > %LISTFILE%
echo ^<html^>      >> %LISTFILE%
echo ^<head^>      >> %LISTFILE%
echo ^<meta charset="GB2312"^>  >> %LISTFILE%
echo ^<title^>显示当前文件夹目录下文件列表^</title^>   >> %LISTFILE%
echo ^<style type=text/css^>A:link{FONT-SIZE:9pt;COLOR:#000000;TEXT-DECORATION: none}      >> %LISTFILE%
echo A:visited{FONT-SIZE:9pt;COLOR:#000000;TEXT-DECORATION:none}A:hover{COLOR:#ff0000; >> %LISTFILE%
echo TEXT-DECORATION: underline}BODY{FONT-SIZE:9pt}TABLE{FONT-SIZE:9pt}^</style^>     >> %LISTFILE%
echo ^</head^>     >> %LISTFILE%
echo ^<body^>     >> %LISTFILE%
echo [PROCESSED BY %0]^<br^> >> %LISTFILE%
for /f "tokens=* delims=" %%i in ('dir *.* /a:-d/s/b') do (
echo ^<a href="%%i" target=_blank^>%%i^</a^>^<br^> >> %LISTFILE%
)
echo ^</body^>    >> %LISTFILE%
echo ^</html^>      >> %LISTFILE%
start .\%LISTFILE%

 效果如下:

<!doctype html>         
<html>      
<head>      
<meta charset="GB2312">  
<title>显示当前文件夹目录下文件列表</title>   
<style type=text/css>A:link{FONT-SIZE:9pt;COLOR:#000000;TEXT-DECORATION: none}      
A:visited{FONT-SIZE:9pt;COLOR:#000000;TEXT-DECORATION:none}A:hover{COLOR:#ff0000; 
TEXT-DECORATION: underline}BODY{FONT-SIZE:9pt}TABLE{FONT-SIZE:9pt}</style>     
</head>     
<body>     
[PROCESSED BY "D:\office2016\显示当前文件夹目录下文件列表.bat"]<br> 
<a href="D:\office2016\list.html" target=_blank>D:\office2016\list.html</a><br> 
<a href="D:\office2016\显示当前文件夹目录下文件列表.bat" target=_blank>D:\office2016\显示当前文件夹目录下文件列表.bat</a><br> 
<a href="D:\office2016\office2016\autorun.inf" target=_blank>D:\office2016\office2016\autorun.inf</a><br> 
<a href="D:\office2016\office2016\office2016activate.bat" target=_blank>D:\office2016\office2016\office2016activate.bat</a><br> 
<a href="D:\office2016\office2016\office2016activate.ps1" target=_blank>D:\office2016\office2016\office2016activate.ps1</a><br> 
<a href="D:\office2016\office2016\office2016setup.bat" target=_blank>D:\office2016\office2016\office2016setup.bat</a><br> 
<a href="D:\office2016\office2016\office2016setup.ps1" target=_blank>D:\office2016\office2016\office2016setup.ps1</a><br> 
<a href="D:\office2016\office2016\readme.htm" target=_blank>D:\office2016\office2016\readme.htm</a><br> 
<a href="D:\office2016\office2016\setup.dll" target=_blank>D:\office2016\office2016\setup.dll</a><br> 
<a href="D:\office2016\office2016\setup.exe" target=_blank>D:\office2016\office2016\setup.exe</a><br> 
<a href="D:\office2016\office2016\sfbactivate.bat" target=_blank>D:\office2016\office2016\sfbactivate.bat</a><br> 
<a href="D:\office2016\office2016\sfbsetup.bat" target=_blank>D:\office2016\office2016\sfbsetup.bat</a><br> 
<!--
--省略--
-->
</body>    
</html>      

截图:

 

posted @ 2017-06-01 16:10  亚北  阅读(10597)  评论(1编辑  收藏  举报