Advanced Siril scripting with bash or DOS

By Cyril Richard

For fans of the command line, Siril allows you to integrate its scripts (a simple suite of Siril commands) into shell scripts (bash or dos) which are much more powerful and allow the management of variables. We will see in this mini tutorial how to create such scripts on a UNIX type platform as well as on Microsoft Windows. The example we are going to present consists of simply resampling a 2x2 bin image into a 1x1 bin, multiplying its size by two with the siril resample command.


The preliminary step is to create the file and make it executable:

touch resample
chmod a+x resample

Edit the file and copy the following text:

#  resample a file
#  used to resample bin 2x2 to 1x1
#  useful for lrgb with l in 1x1 and rgb in 2x2
version=$(siril --version |awk '{print $2}')

siril-cli -i ~/.siril/siril.cfg -s - <<ENDSIRIL >/dev/null 2>&1
requires $version
setext $ext
load $1
resample 2.0
save $1

Save the file then close it, then all you have to do is run the script by typing

./resample filename

or, if the images contain the pattern 2x2 in the filename:

for i in $(/bin/ls *.fits |grep 2x2); do ./resample $i; done

Note: for MacOS systems, the script work the same way, only the siril path must be updated with something like /Applications/

Microsoft Windows

Create an empty file with the following command line

copy NUL resample.bat

or of course through the UI.

Edit the file and copy the following text:

echo OFF
FOR /F "tokens=2 " %%g IN ('siril --version') do (SET version=%%g)
set ext=fits

echo requires %version%
echo setext %ext%
echo load %1
echo resample 2.0
echo save %1
echo close
) | "C:\Program Files\SiriL\bin\siril-cli.exe" -s - >nul 2>&1


Save the file the close it. You can now run the script either by dragging a picture onto its icon or by typing the command :

resample.bat filename


This example is simple and does not add much, however it shows that it is possible to script every step of the image processing process using the power of shell scripts coupled with that of Siril.