A. 求教,如何使用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
B. 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
C. 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
D. winrar的bat批处理命令 ,如何批量解压缩到每个单独的文件夹
保证能用,建一个bat文件,把下面的拷贝进去,然后和你那些rar放到一专个目录里面属
for
%%i
in
(a.rar,b.rar,c.rar)
do
"C:\Program
Files\WinRAR\rar.exe"
x
%%i
.\%%~ni\