OK, I got it working, thanks to JasonJ's suggestion.
Here's how, for those who'd be interested in doing it.
To use three different custom view sets named "driving", "onboard" and "exotic" (to keep my previous examples) with a single command that cycles between them:
1. Go to LFS\data and duplicate the views folder. Name the copy "views_onboard". Duplicate it again, and name the second copy "views_exotic".
2. Go to LFS's folder and create a text file named switchViews.bat (at the same level as the data folder).
3. Set the contents of this file to:
@echo off
setlocal
:: determine the current view
set flDriving=1
set flOnboard=1
set flExotic=1
if exist data\views_driving set flDriving=0
if exist data\views_onboard set flOnboard=0
if exist data\views_exotic set flExotic=0
:: make sure the folders are set as expected
if %flDriving%==0 if %flOnboard%==0 if %flExotic%==0 goto error1
if %flDriving%==1 if %flOnboard%==1 if %flExotic%==1 goto error2
:: do the switching
if %flDriving%==1 (
rename data\views views_driving
rename data\views_onboard views
goto end
)
if %flOnboard%==1 (
rename data\views views_onboard
rename data\views_exotic views
goto end
)
if %flExotic%==1 (
rename data\views views_exotic
rename data\views_driving views
goto end
)
:: report errors
:error1
echo Error: cannot determine the current view.
pause
goto end
:error2
echo Error: the required folders weren't found.
pause
goto end
:end
endlocal
exit
4. Save and close that file. Each time this script runs, it will rename the "views" folder into either "views_driving", "views_onboard" or "views_exotic", depending on the current set, and will rename into "views" the next of these three folders in the cycle. So calling the script the first time will switch from the driving set to the onboard one, the second time it will switch the set from onboard to exotic, the third time from exotic to driving, and so on. You can test it outside of LFS by double-clicking on it.
5. Launch LFS , go to Options > Game and set a key to run the script. For example set CTRL + F12 to /exec switchViews.bat.
Voilà, it's all set up. Since you didn't create a folder named "views_driving", this is the set which is currently active. Go to single player mode, and make sure the custom views of the cars you use are set in the driving position. When you're done, press CTRL + F12 to switch to the next views set (onboard).
Then, you just have to change the view (by pressing V or SHIFT + V) to switch to the new custom view if it wasn't active when you triggered the script, or if it was active, to switch to another view and back to the custom one to force it to load the new camera settings. Of course the first time the views won't be any different, since you just duplicated the original views folder. But now the active set is the onboard one, so go to Options > View and set your onboard camera. When you're done, run the script again, and set your "exotic" camera.
There's just a little problem: if you're running LFS in windowed mode, when you invoke the script you'll just see a Terminal window flashing briefly as the script is executed, and this is OK. But if you're in full screen mode, LFS will be minimized to the tasks bar and you'll have to click on it to restore it. It's not a big problem, because this isn't intended to be used while driving, but it seems to be a limitation of LFS. Not sure if it's a bug or a feature. If anyone knows a way to avoid it, please let me know.
I'd still like to be able to script the custom view, but in the meantime this is not too bad as workaround.