这是脚本。目标是将文件夹中的Rar文件提取到特定文件夹。问题是我需要WinRar的路径更改为Program Files程序文件(x86)不在系统上。我怎样才能做到这一点?谢谢!
@echo off
@set local
set dirA=C:\Users\%username%\Desktop
\SpearsCraftBox\Batches
set dirE=C:\Users\%username%\AppData
\Roaming\.minecraft
set dirC=C:\Users\%username%\Desktop
\SpearsCraftBox\Batches
cd %dirA%
设置路径=“C:\ Program Files(x86)\ WinRAR \”;%path%
echo.
echo All files in %dirA% to be uncompressed
echo.
echo.
FOR %%i IN (*.rar) do (
unrar x "%%~ni.rar" "%dirE%"
move "%%~ni.rar" "%dirC%"
echo completed uncompressing "%%i" and moved
archives or archive to "%dirC%"
)
goto eof
:eof
echo.
echo "Task Completed"
echo.
答案 0 :(得分:3)
为Program Files目录定义了环境变量:%ProgramFiles%
和%ProgramFiles(x86)%
。
IF EXIST "%ProgramFiles(x86)%\WinRAR" (
SET pth="%ProgramFiles(x86)%\WinRAR"
)
IF EXIST "%ProgramFiles%\WinRAR" (
SET pth="%ProgramFiles%\WinRAR"
)
IF NOT EXIST %pth% (
ECHO WinRar not found.
GOTO :EOF
)
...
"%pth%unrar" x "%%~ni.rar" "%dirE%"
...