不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件放一起运行
@echo off
rem 根据给出的两个对应的关键字,将文件名称中分别包含有这两个关键字的文件剪切/移动到同个文件夹里
mode con lines=3000
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
cd /d "%~dp0"
for /f "delims=:" %%a in ('type "%~f0"^|findstr /n "^exit$"') do set last=%%a
for /f "skip=%last% tokens=1* delims=|" %%a in ('type "%~f0"') do (
set "n="
setlocal enabledelayedexpansion
for /f "delims=" %%c in ('dir /a-d/b "*%%a*.*"') do (
if not defined n set "n=%%~na"
echo;"%%c" --^> "!n:~,12!"
)
if defined n (
for /f "delims=" %%c in ('dir /a-d/b "*%%b*.*"') do (
echo;"%%c" --^> "!n:~,12!"
)
)
endlocal
echo;-------------------------------
)
echo;%#% +%$%%$%/%@% %z%
pause
exit
8AM0XB9H0809|7085C2850A44
关键字3|关键字4
关键字5|关键字6