如何通过使用Batch查找扩展名来从未知文件名设置变量?

问题描述 投票:1回答:1

我当前正在编写以执行目录中未知的名为checksum的文件。问题是我不知道如何在目录中搜索.sfv.md5并将找到的校验和文件设置为变量,以后可以在脚本中执行。

@echo off
set quicksfv="%ProgramFiles%\QuickSFV\quicksfv.exe"

if exist "*.sfv" (
    goto sfvcheck
    )
    and (
    set EXT="sfv"
)
else (
    goto skip
)
if exist "*.md5" (
    goto sfvcheck
    )
    and (
    set EXT="md5"
)
    else (
    goto skip
)
/*
this is what i would like to add if the checksum file exist
*/

GetFileName of checksum file
set CHECKSUM="checksumfilename"

:sfvcheck
quicksfv "%CHECKSUM%.%EXT%"

:skip
echo. No checksum file was found!
pause
exit
file batch-file variables search
1个回答
0
投票

我对另一个CRC应用程序执行了此过程,这有点不同。它仅支持SFV,但...

@echo off

set SFVCHECK="C:\dont_alter\pure-sfv.exe"
cd %1
set errorlevel=0
%SFVCHECK% -t -i
if errorlevel 10 (
    echo Different CRC or a missing file...
    pause
    exit /B %errorlevel%
    )
if errorlevel 11 (
    echo Different CRC...
    pause
    exit /B %errorlevel%
    )
if errorlevel 12 (
    echo Missing file...
    pause
    exit /B %errorlevel%
    )
    ```
© www.soinside.com 2019 - 2024. All rights reserved.