rem 根据一个txt文本文件内列出的文件名称前缀字符,从一个指定目录里查找出符合条件的子文件夹并拷贝/复制到另一个指定目录里
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "oldfolder=D:\xxx\原文件夹"
set "newfolder=E:\yyy\新文件夹"
set "txtfille=***.txt"
if not exist "%oldfolder%" (echo"%oldfolder%" 未找到&pause&exit)
if not exist "%newfolder%" md "%newfolder%"
if not exist "%txtfille%" (echo"%txtfille%" 未找到&pause&exit)
if "%oldfolder:~-1%" equ "\" set "oldfolder=%oldfolder:~,-1%"
if "%newfolder:~-1%" equ "\" set "newfolder=%newfolder:~,-1%"
for /f "delims=" %%a in ('type "%txtfille%"') do (
for /f "delims=" %%b in ('dir /ad-h/b "%oldfolder%\%%a_*" 2^>nul') do (
echo"%oldfolder%\%%~nxb" --^>"%newfolder%"
)
)
echo%#% +%$%%$%/%_% %z%
pause
exit
不清楚你的实际文件/情况,仅以问题中的样例/说明为据复制粘贴到记事本,另存为xx.bat,编码选ANSI@echo off
rem 判断/检测指定文件夹/目录下是否存在指定文件
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
set "htmlfile=%tmp%\index.html"
if not exist "%htmlfile%" (
echo调用另外一个bat
goto end
)
echo继续往下执行
:end
echo%#% +%$%%$%/%@% %z%
pause
exit
用find 筛选
如
SET "排除目录=文件夹C"FOR /F "delims=" %%i IN (`DIR /s /b *.hex ^|find /v "%cd%\%排除目录%\"`) DO (
echo,%%i
)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)