gpt4 book ai didi

if-statement - 如果程序文件(x86)批量不存在,如何将路径=设置为程序文件?

转载 作者:行者123 更新时间:2023-12-04 05:32:19 26 4
gpt4 key购买 nike

这是脚本。目标是将文件夹中的 Rar 文件解压缩到特定文件夹。问题是我需要将 WinRar 的路径更改为 Program Files 是 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%

set path="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.

最佳答案

为 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%"
...

关于if-statement - 如果程序文件(x86)批量不存在,如何将路径=设置为程序文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12418242/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com