Ⅰ bat批量复制并压缩
不清楚你的实际文件/情况,仅以问题中的说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI
@echo off
rem 从一个指定文件夹里查找出多个指定名称的jpg图片文件并复制压缩打包到另一个指定文件夹里
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
set "exefile=C:\Program Files\WinRAR\WinRAR.exe"
set "oldfolder=D:\xxx\原文件夹"
set "newfolder=D:\xxx\新文件夹"
if not exist "%exefile%" (echo;"%exefile%" not found&pause&exit)
if not exist "%oldfolder%" (echo;"%oldfolder%" not found&pause&exit)
if not exist "%newfolder%" (md "%newfolder%")
for /f "delims=" %%a in ('dir /a-d/b/s "%oldfolder%\*.jpg"') do (
set "f="
for %%b in (
"文件1.jpg"
"文件2.jpg"
"文件3.jpg"
"文件4.jpg"
) do (
if /i "%%~nxa" equ "%%~b" (
echo;"%%a"
"%exefile%" a -y -ep1 "%newfolder%\xxx.rar" "%%a"
)
)
)
echo;%#% +%$%%$%/%@% %z%
pause
exit
Ⅱ bat脚本,实现压缩当前文件夹下的第二层文件夹分别为zip压缩包
不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI
@echo off
rem 将当前目录下指定层级的子文件夹进行压缩打包
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
cd /d "%~dp0"
set "exefile=C:\Program Files\WinRAR\WinRAR.exe"
if not exist "%exefile%" (echo;"%exefile%" 未找到&pause&exit)
for /f "delims=" %%a in ('dir /ad/b') do (
for /f "delims=" %%b in ('dir /ad/b ".\%%a\" 2^>nul') do (
"%exefile%" a -y -r -ep1 ".\%%~nxa\%%~nb.zip" ".\%%~nxa\%%~nxb\"
)
)
echo;%#% +%$%%$%/%_% %z%
pause
exit
Ⅲ 求教,如何使用bat复制指定文件夹(或文件)到指定目录下,并且压缩整个文件夹(或文件)
不清楚你的实际文件/情况,仅以问题中的样例/说明为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI
@echo off
rem 将一个指定文件夹里的所有文件拷贝/复制到另一个文件夹里并进行压缩打包
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@% %z%
set "oldfolder=D:\A"
set "newfolder=F:\B"
set "exefile=C:\Program Files\WinRAR\WinRAR.exe"
if not exist "%oldfolder%" (echo;"%oldfolder%" not found&goto end)
if not exist "%newfolder%" md "%newfolder%"
if not exist "%exefile%" (echo;"%exefile%" not found&goto end)
x "%oldfolder%" "%newfolder%\" /y /e /q /r /h
"%exefile%" a -y -r -ep1 ".\xxx.zip" "%newfolder%\*"
:end
echo;%#% +%$%%$%/%@% %z%
pause
exit
Ⅳ BAT怎么压缩指定文件夹
@echooff
rem批量压缩/打包多个文件夹
set#=Anyquestion&set$=Q&set/az=0x53b7e0b4
title%#%+%$%%$%%z%
cd/d"%~dp0"
set"exefile=C:ProgramFiles7-Zip7z.exe"
ifnotexist"%exefile%"(echo;"%exefile%"notfound&gotoend)
for/f"delims="%%ain('dir/ad/b')do(
echo;"%%a"--^>"%%~na.7z"
"%exefile%"a-t7z"%%~na.7z"".\%%a*"-r
)
:end
echo;%#%+%$%%$%%z%
pause