No, changing the writesteps option to $(intermediate_steps_folder) will not work as expected.
In the original code, the writesteps option is a string that contains the path to the folder where the intermediate steps should be stored. By using $(joinpath(intermediate_steps_folder, "Scan$scan_number")), you are ensuring that the intermediate steps are stored in a folder that is named based on the current scan number.
If you change writesteps to $(intermediate_steps_folder), then Julia will interpret this as a command to run the intermediate_steps_folder command, rather than using it as a path. This will result in an error, as there is no command named intermediate_steps_folder.
To achieve the same functionality as the original code, you can use the joinpath function to construct the path to the intermediate steps folder, but pass the intermediate_steps_folder as a string, like this: