0

I'm trying to make that when I run the script and there's a .wem file in my "input" folder, it will directly convert it into my "output" folder. But I can't seem to figure this out.

@Echo off
Echo -------------------------------------------------------------------------------------
For %%f in ("%~dp0input\*.wem") do "./ww2ogg024/ww2ogg.exe" --pcb "./ww2ogg024/packed_codebooks_aoTuV_603.bin" "%%f"
For %%f in ("%~dp0outnput\*.ogg") do revorb.exe "%%f" 
Echo -------------------------------------------------------------------------------------
pause

Does anyone know what am I doing wrong? I'm kind of a starter with this.

  • The best advice I can give you at this stage, is: `1.` Determine the command line options for your two executables, _(so that you know what information they need to perform the tasks you require of them)_. `2.` Find out how the `For` command works! _(Open up a Command Prompt window, type `for /?`, press the 'Enter' key, and read all of the presented information)_. – Compo Apr 25 '20 at 14:03

1 Answers1

0

I have no knowledge of your executables, however, a quick search revealed their command line options:

ww2ogg input.wav [-o output.ogg] [--inline-codebooks] [--full-setup]
                 [--pcb packed_codebooks.bin]

 

revorb <input.ogg> [output.ogg]

From that information, I'd suggest that you try this sort of methodology, (Remarks included as explanation):

@Echo Off
Rem Define the location for ww2ogg.exe.
Set "WemToOggPath=C:\SomeLocation\ww2ogg024"
Rem Define the location for revorb.exe.
Set "MyRevorbPath=C:\SomeLocation"

Rem Exit if the required executables and input files are not available.
If Not Exist "%WemToOggPath%\ww2ogg.exe" Exit /B 1
If Not Exist "%MyRevorbPath%\revorb.exe" Exit /B 1
If Not Exist "%~dp0input\*.wem" Exit /B 1
Rem Create output directory if it does not already exist along side this script.
If Not Exist "%~dp0output\" MD "%~dp0output"

Echo -------------------------------------------------------------------------------------
Rem Loop through each .wem file located inside the a directory named input along side this script.
For %%I In ("%~dp0input\*.wem") Do (
    Rem Run ww2ogg.exe against each .wem file outputting them to the same directory but with an .ogg extension.
    "%WemToOggPath%\ww2ogg.exe" "%%I" -o "%%~dpnI.ogg" --pcb "%WemToOggPath%\packed_codebooks_aoTuV_603.bin"
    Rem If the last ww2ogg.exe process was successful then.
    If Not ErrorLevel 1 If Exist "%%~dpnI.ogg" (
        Rem If there is still a .wem file delete it.
        If Exist "%%I" Del "%%I"
        Rem Run revorb.exe against the .ogg file outputting it to the output directory along side this script.
        "%MyRevorbPath%\revorb.exe" "%%~dpnI.ogg" "%~dp0output\%%~nI.ogg"
        Rem If the last revorb.exe process was successful and there is still a matching .ogg file inside the input directory delete it.
        If Not ErrorLevel 1 If Exist "%%~dpnI.ogg" If Exist "%~dp0output\%%~nI.ogg" Del "%%~dpnI.ogg"
    )
)
Echo -------------------------------------------------------------------------------------
Pause

As I don't know those utilities, I have tried to assume nothing, so if your conversion processes are not leaving the unconverted files behind, the script could probably be made smaller.

Please read through the Remarks to understand exactly what it does, before you run it, and most importantly, ensure that you modify C:\SomeLocation on lines 3 and 5 to those which hold your two executables. (Please do not leave trailing path separators on those directories). I would then suggest that you try the script from within a test input directory, and against some copied .wem files, before attempting it in your production environment.

Compo
  • 36,585
  • 5
  • 27
  • 39