:::::::::::::::::::::::::
:: REAPER Simple Batch ::
::    Aaron Cendan     ::
:::::::::::::::::::::::::
:: 1. Place files in /_raw
:: 2. Run .bat file with name corresponding to your preferred FX Chain
:: 3. Trigger reaper batch conversion 
:: 4. Output files will be in /_processed after conversion

:: - There are additional options for editing this script in the "Global Variables" section below
:: - Feel free to copy this .bat file with a new name & new FX name in the same folder root!

::::::::::::::::::::::::::::::::
:: SCRIPT SETUP - DO NOT EDIT ::
::::::::::::::::::::::::::::::::
@echo off
setlocal enabledelayedexpansion

::::::::::::::::::::::
:: GLOBAL VARIABLES ::
::::::::::::::::::::::

:: Pad file start, in seconds (supports negative values to trim start)
set PAD_START=0.00

:: Pad file end, in seconds (supports negative values to trim end)
set PAD_END=0.00

:: To use a local REAPER install instead of the portable install packaged with this script...
:: 1. Set the filepath in quotes below to your local REAPER install
:: 2. Comment out line 1 of "Trigger Command" code block
:: 3. Uncomment line 2 of "Trigger Command" code block. Save/close this file.
set reaper="C:\Program Files\REAPER (x64)\REAPER.exe"

:: File list initialization - DO NOT EDIT THIS
:: Refer to "\_reaper\filelist.txt" for output log
set filelist=

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

::::::::::::::::::::::
:: NEWLINES    !\n! ::
::::::::::::::::::::::
(set \n=^
%=Do not remove this line=%
)

::::::::::::::::::::::
::  BUILD FILELIST  ::
::::::::::::::::::::::
:: Searches for wav files in \_raw\ directory and outputs to \_processed\

For /R .\_raw %%G IN (*.wav) do (
	set filelist=!filelist!%%~G^	%cd%\_processed\%%~nG%%~xG!\n!
)

::::::::::::::::::::::
::  BATCH CONFIG    ::
::::::::::::::::::::::
set filelist=!filelist!^<CONFIG!\n!	PAD_END %PAD_END%!\n!	PAD_START %PAD_START%!\n!	FXCHAIN "%cd%\%~n0.RfxChain"!\n!^>

::::::::::::::::::::::
::   WRITE TO FILE  ::
::::::::::::::::::::::
echo !filelist! > "%cd%\_reaper\filelist.txt"
endlocal

::::::::::::::::::::::
::  TRIGGER COMMAND ::
::::::::::::::::::::::
"%cd%\_reaper\reaper\reaper" -batchconvert "%cd%\_reaper\filelist.txt"
::%reaper% -batchconvert "%cd%\_reaper\filelist.txt"

echo Finished batch processing^!
@echo on