mercredi 27 mars 2019

Issue with the 'If Exisit' and 'else' function in Batch Script

So I want to run the operation (denoated by S1) in sub directories only under the condition that the sub directories contain a .mkv file with and a .ttf OR .otf file. This what I have done do far...

For /F Delims^=^ EOL^= %%A In ('Dir/B/AD 2^>Nul^|FindStr/IVXC:"Revised"'
) Do If Exist "%%A\*.mkv" ( 
If Exist "%%A\*.ttf" (
        If Not Exist "Revised\" MD "Revised" 2>Nul||Exit /B
        Call :S1 "%%A")
) else ( 
If Exist "%%A\*.otf" (
        If Not Exist "Revised\" MD "Revised" 2>Nul||Exit /B
        Call :S1 "%%A"))
GoTo :EOF

The issue is the S1 operation only takes place when there is a .otf file and not the .ttf file. However if I do this...

For /F Delims^=^ EOL^= %%A In ('Dir/B/AD 2^>Nul^|FindStr/IVXC:"Revised"'
) Do If Exist "%%A\*.mkv" ( 
Do If Exist "%%A\*.ttf" (
        If Not Exist "Revised\" MD "Revised" 2>Nul||Exit /B
        Call :S1 "%%A")
) else ( 
If Exist "%%A\*.otf" (
        If Not Exist "Revised\" MD "Revised" 2>Nul||Exit /B
        Call :S1 "%%A"))
GoTo :EOF

By adding a Do right before the If Exist in the 3rd line, the script functions as intended but the I would keep getting prompted

'Do' is not recognized as a internal or external command

Could I please get some help with the issue of getting the script to function as intended without the prompts?

Aucun commentaire:

Enregistrer un commentaire