Ⅰ 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