DOS batch for updating presets
Maybe this is helpful for one or another. I wrote a little batch file that updates my already created presets to the most recent version. HSM reflection is under heavy development, and every other day there’s a new version with great new features. Unfortunately, in most cases old presets are not compatible with the new version. The shader chain is different and the biggest problem: some parameters are being dropped and new ones added.
It’s a pain in the a… to either a) manually create your presets from scratch again or b) copy & paste every parameter into a newly created preset.
As of today I had already created ~ 30 presets. So I decided to write a small, helping dos batch which does a very simple job:
It creates a new shader preset file for all existing shader presets in the same directory and saves them into a newly created subfolder _new _\ .
The batch file inserts the new shader chain (first part of the preset), and then it appends all parameters from the old presets. For me this works pretty well.
Here’s how to use it:
- start retroarch
- load HSM’s new preset for the kind of shaders presets you want to update (i.e. “hsm-mega-bezel-reflection-crt-guest-dr-venom.slangp”)
- Apply changes. Retroarch automatically creates a new preset file with default parameters. You can find it here: [retroarch root]\shaders\retroarch.slangp
- Now create a new folder, for example “HSM Preset Update” on your desktop (or whereever you want)
- copy retroarch.slangp to this new folder and rename “retroarch.slangp” to “template.txt”
- now copy all your existing presets that are based on the same preset (in this example it’s “hsm-mega-bezel-reflection-crt-guest-dr-venom.slangp”) to the newly created “HSM Preset Update” directory (if you want to create updated files, of course)
- Now create a new txt file in the same directory and rename it to “HSM_preset_updater.bat”
- Copy the following code into that batch-file:
@echo off setlocal EnableDelayedExpansion set template=template.txt if exist _new_ ( echo Folder _new_ already exists echo Please delete folder _new_ and restart updater. Thx. pause exit ) mkdir _new_ for %%a in ("*.slangp") do ( set shader=%%~na.slangp set new_shader=.\_new_\!shader! echo.>!new_shader! set params=false for /f "tokens=*" %%a in (%template%) do ( set Line=%%a set Anfang=!Line:~0,10! if !params! EQU false echo !Line!>>!new_shader! if !Anfang! EQU parameters set params=true ) for /f "tokens=*" %%a in (!shader!) do ( set Line=%%a set Anfang=!Line:~0,10! if !params! EQU false echo !Line!>>!new_shader! if !Anfang! EQU parameters set params=false ) echo !new_shader! created ) pause
Now you can execute the batch file. It will create a subfolder called _new _ and will create an updated version of each file with the extension “slangp”. That’s it.
You can now use your newly generated, updated presets.
What else? Maybe you should know this:
- If you had manually added shaders to the original presets chain, you have to add them to the new presets again manually, obviously. The chains change, so this cannot be automated. You have to do it by yourself
- Some parameters from the old preset won’t exist in the new preset anymore, but still are copied by the batch to the new preset file. That’s no problem: they will be ignored, and the next time you apply changes or save your shader, they will automatically be eliminated.
- Same for newly added parameters, that didn’t exist before: they will of course be missing in first place after the creation, but once you use the new preset, they will automatically be filled with the default values - and once you save or apply changes, they will show up in your preset file.
An remember, like always: use at your own risk