杰网资源 Design By www.escxy.com

判断输入路径是不是文件夹,如果是,则获取文件夹下的所有文件名(包括子文件夹下的)
如果要文件名带上路径,则需要在dir这一句的%%~nxi上作改动

@echo off
:: 判断输入路径是不是文件夹,如果是,则获取文件夹下的所有文件名(包括子文件夹下的)
:: 如果要文件名带上路径,则需要在dir这一句的%%~nxi上作改动
::       code by jm CMD@XP 2006-7-20
if exist list.txt del list.txt /q
:input
cls
set input=:
set /p input=      请输入要进行判断的路径:
set "input=%input:"=%"
:: 上面这句为判断%input%中是否存在引号,有则剔除。
if "%input%"==":" goto input
if not exist "%input%" goto input
for %%i in ("%input%") do if /i "%%~di"==%%i goto input
pushd %cd%
cd /d "%input%">nul 2>nul || exit
set cur_dir=%cd%
popd
for /f "delims=" %%i in ('dir /b /a-d /s "%input%"') do echo %%~nxilist.txt
if not exist list.txt goto no_file
start list.txt
exit

:no_file
cls
echo    %cur_dir% 文件夹下没有单独的文件
pause

经过小编测试,正常运行。

标签:
bat文件列表

杰网资源 Design By www.escxy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
杰网资源 Design By www.escxy.com