我想压缩所有包含单词(Album)的文件夹,这些文件夹具有以下结构
Michael Jackson\Invincible (Album)
Michael Jackson\Thriller (Album)
Luciano Pavarotti\'O sole mio (Single)
Queen\Bohemian Rhapsody (Single)
到目前为止我已经尝试过这个,但它对我来说不起作用。
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%f in ('dir /s /b /ad "*(Album)"') do (
set "filename=%%~nf"
"%ProgramFiles%\WinRAR\Rar.exe" a -ep1 -idq -r -y %filename%
echo %filename%
)
pause
答案1
按照如下方法解决问题
@echo off
setlocal enabledelayedexpansion
for /f "tokens=*" %%f in ('dir /s /b /ad "*(Album)"') do (
set "filename=%%~nf"
"%ProgramFiles%\WinRAR\Rar.exe" a "-cpNo compression" -ep1 -r -y "%%~nf.rar" "%%~f"
)
pause