问题
Made a simple batch script to create a .sfv for each file within the folder. I'm far from being a coder but I patched this together from various sites and made it work:
for %%f in (*) do (cfv -C -f"%%f".sfv -tsfv "%%f")
The issue is, if I run this batch file more than once, existing files get checked again and a separate .sfv file is created as a *.sfv.sfv
Just wondering, how can this be written to ignore checking a file/writing a new .sfv if a .sfv exists? Thank you!
Edit: I tried the following:
@echo off
@For /F "EOL=? Delims=" %%G In ('Dir /B /A:-D-S-L ^| "%__AppDir__%findstr.exe" /EILV ".sfv"') Do @If Not Exist "%%~nG.sfv" fsum -js "%%G" > "%%G.sfv"
It does an excellent job of not adding a .sfv.sfv file every time its ran, great! Issue now though is when the script is ran, it has to read each file regardless if there is a .sfv file beside it or not.
The idea here is to have the script see that there is a sfv file with the same filename as the original file, and if that .sfv file exists skip it entirely and move to the next file until there are no more files without a .sfv associated with it. I know it's not easy to put this into words so let me try and give an example.
/parent directory/
linuxiso1.iso
linuxiso2.iso
linuxiso3.iso
*Cujo67 runs Batch.bat script*
/parent directory/
linuxiso1.iso
linuxiso1.sfv
linuxiso2.iso
linuxiso2.sfv
linuxiso3.iso
linuxiso3.sfv
With the current code it has to crunch each .iso file and then sees that it's already got a .sfv in the directory, and skips it. Wondering how to have this script just avoid running the checksum command entirely if there is already as corresponding .sfv alongside the .iso file. Hope that's a bit more clear, thanks.
来源:https://stackoverflow.com/questions/63872074/need-batch-script-to-skip-over-existing-sfv-files-when-ran-a-second-time