对一个大任务BATCH使用多个if exist和if not exist存在问题



所以我正在处理一个批处理文件,当你打开这个文件时,它会清除这些特定的文件,但我想让很多人公开发布它,但我在使用4个IF NOT EXIST和4个IF EXIST行来执行这些文件时遇到了问题。

我试着寻找多个来源或尝试过这项工作的人,但我似乎找不到任何接近运行这么大任务的东西

这是我当前的代码:

title Zyorby Cleaner V2  ENB Remover
cls
if exist C:Program FilesEpic GamesGTAVenbseries (
if exist D:Program FilesEpic GamesGTAVenbseries (
if exist C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries (
if exist D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries (
rmdir /s /q "C:Program FilesEpic GamesGTAVenbseries"
del /s /q "C:Program FilesEpic GamesGTAVd3d11.dll"
del /s /q "C:Program FilesEpic GamesGTAVd3dcompiler_46e.dll"
del /s /q "C:Program FilesEpic GamesGTAVenbadaptation.fx"
del /s /q "C:Program FilesEpic GamesGTAVenbbloom.fx"
del /s /q "C:Program FilesEpic GamesGTAVenbeffect.fx"
del /s /q "C:Program FilesEpic GamesGTAVenbeffectpostpass.fx"
del /s /q "C:Program FilesEpic GamesGTAVenblens.fx"
del /s /q "C:Program FilesEpic GamesGTAVenblightsprite.fx"
del /s /q "C:Program FilesEpic GamesGTAVenblocal.ini""
del /s /q "C:Program FilesEpic GamesGTAVenbseries.ini"
rmdir /s /q "D:Program FilesEpic GamesGTAVenbseries"
del /s /q "D:Program FilesEpic GamesGTAVd3d11.dll"
del /s /q "D:Program FilesEpic GamesGTAVd3dcompiler_46e.dll"
del /s /q "D:Program FilesEpic GamesGTAVenbadaptation.fx"
del /s /q "D:Program FilesEpic GamesGTAVenbbloom.fx"
del /s /q "D:Program FilesEpic GamesGTAVenbeffect.fx"
del /s /q "D:Program FilesEpic GamesGTAVenbeffectpostpass.fx"
del /s /q "D:Program FilesEpic GamesGTAVenblens.fx"
del /s /q "D:Program FilesEpic GamesGTAVenblightsprite.fx"
del /s /q "D:Program FilesEpic GamesGTAVenblocal.ini"
del /s /q "D:Program FilesEpic GamesGTAVenbseries.ini"
rmdir /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3d11.dll"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3dcompiler_46e.dll"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbadaptation.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbbloom.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffect.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffectpostpass.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblens.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblightsprite.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblocal.ini"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries.ini"
rmdir /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3d11.dll"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3dcompiler_46e.dll"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbadaptation.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbbloom.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffect.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffectpostpass.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblens.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblightsprite.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblocal.ini"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries.ini"
echo %DATE% %TIME% - ENB has been removed >> %userprofile%Downloadslogs.txt
cls
echo.
echo              ----------------------------------
echo              -   your ENB has been cleaned    -
echo              - to go back to the home screen: -
echo              ----------------------------------
echo.
)
)
)
)
if not exist C:Program FilesEpic GamesGTAVenbseries (
if not exist D:Program FilesEpic GamesGTAVenbseries (
if not exist C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries (
if not exist D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries (
echo %DATE% %TIME% - could not find enbseries folder >> %userprofile%Downloadslogs.txt
cls
echo.
echo           --------------------------------------
echo           -   your ENB could not be found :(   -
echo           --------------------------------------
echo.
)
)
)
)
)
pause
goto main```

我很快就解决了这个问题,我用了很多其他的方法做了一个简单的检查表,但它有效了。我不确定是否有更有效的方法,但目前这对我有效


这是固定代码:

:x
title Zyorby Cleaner V2  ENB Remover
cls
if exist "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries" (
goto enbyes
) else (
if exist "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries" (
goto enbyes
) else (
if exist "C:Program FilesEpic GamesGTAVenbseries" (
goto enbyes
) else (
if exist "D:Program FilesEpic GamesGTAVenbseries" (
goto enbyes
) else (
goto enbno
)
)
)
)

:enbyes
rmdir /s /q "C:Program FilesEpic GamesGTAVenbseries"
del /s /q "C:Program FilesEpic GamesGTAVd3d11.dll"
del /s /q "C:Program FilesEpic GamesGTAVd3dcompiler_46e.dll"
del /s /q "C:Program FilesEpic GamesGTAVenbadaptation.fx"
del /s /q "C:Program FilesEpic GamesGTAVenbbloom.fx"
del /s /q "C:Program FilesEpic GamesGTAVenbeffect.fx"
del /s /q "C:Program FilesEpic GamesGTAVenbeffectpostpass.fx"
del /s /q "C:Program FilesEpic GamesGTAVenblens.fx"
del /s /q "C:Program FilesEpic GamesGTAVenblightsprite.fx"
del /s /q "C:Program FilesEpic GamesGTAVenblocal.ini""
del /s /q "C:Program FilesEpic GamesGTAVenbseries.ini"
rmdir /s /q "D:Program FilesEpic GamesGTAVenbseries"
del /s /q "D:Program FilesEpic GamesGTAVd3d11.dll"
del /s /q "D:Program FilesEpic GamesGTAVd3dcompiler_46e.dll"
del /s /q "D:Program FilesEpic GamesGTAVenbadaptation.fx"
del /s /q "D:Program FilesEpic GamesGTAVenbbloom.fx"
del /s /q "D:Program FilesEpic GamesGTAVenbeffect.fx"
del /s /q "D:Program FilesEpic GamesGTAVenbeffectpostpass.fx"
del /s /q "D:Program FilesEpic GamesGTAVenblens.fx"
del /s /q "D:Program FilesEpic GamesGTAVenblightsprite.fx"
del /s /q "D:Program FilesEpic GamesGTAVenblocal.ini"
del /s /q "D:Program FilesEpic GamesGTAVenbseries.ini"
rmdir /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3d11.dll"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3dcompiler_46e.dll"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbadaptation.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbbloom.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffect.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffectpostpass.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblens.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblightsprite.fx"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblocal.ini"
del /s /q "C:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries.ini"
rmdir /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3d11.dll"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Vd3dcompiler_46e.dll"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbadaptation.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbbloom.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffect.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbeffectpostpass.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblens.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblightsprite.fx"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venblocal.ini"
del /s /q "D:Program Files (x86)SteamsteamappscommonGrand Theft Auto Venbseries.ini"
echo %DATE% %TIME% - ENB has been removed >> %userprofile%Downloadslogs.txt
cls
echo.
echo              ----------------------------------
echo              -   your ENB has been cleaned    -
echo              - to go back to the home screen: -
echo              ----------------------------------
echo.
pause
goto main
:enbno
echo %DATE% %TIME% - could not find enbseries folder >> %userprofile%Downloadslogs.txt
cls
echo.
echo           --------------------------------------
echo           -    your ENB could not be found     -
echo           --------------------------------------
echo.
pause
goto main

解释:

基本上,它会遍历用户文件并检查文件夹是否在那里,如果是的话,它会被发送到:enbyes部分,该部分只是删除文件夹和文件的部分,但如果找不到文件夹,它会将其与其他文件夹一起发送到下一个链中,并继续这样做,直到它到达没有选项的末尾。一旦代码到达那里,它就会将其发送到:enbno部分,这只是说它找不到想要找到的东西。

相关内容

  • 没有找到相关文章

最新更新