I'll start by apologising for having to ask such a basic question, I'm sure it's a really simple fix but I can't find the information I'm looking for (or adapt the information I've found to my situation). I'm new to writing batch files, I only started because I want to make the execution of an R-Script easy for people who don't use R.
So the following code runs an R-Script just fine, the script exists in a folder called 'R Files' and the script itself directs its outputs to the 'Output' folder, where the 'R Files' and 'Output folders share the same parent folder.
R --vanilla --quiet <growth_plot_driver.R >console_output.txt
However, considering that other users of this code are unlikely to place the parent folder in the same location that I did I thought it would be best to specify the input and output files in variables. This is where I run into problems, of the "The system cannot find the file specified" kind. I've tried many variations of the following code.
set "path1=%cd%\growth_plot_driver.R"
cd..
cd Output
set "path2=%cd%\console_output.txt"
R --vanilla --quiet <%path1% >%path2%
But as I said, I'm new to this and if there's a better way to go about this I would grateful to hear about it.