r - Windows batch script - parse and expand the variable to pass as a string to external program? -


i want use relative file path command line argument example , assessment below demonstrate, variable passes \..\ string, doesn't evaluate it.

can can force command line parse , expand variable string?

: example:  have r script file want launch command line:  set rpath=c:\program files\r\r-3.1.0\bin\rscript.exe set rscript=%cd%\..\..\hcf_v9.r  set sourcefile=%cd%\..\source\  echo string used source location - %sourcefile%  "%rpath%" "%rscript%" %sourcefile% 

the inclusion of \..\ works in call r external program because batch file can resolve it's own commands.

the variable of sourcefile doesn't work because sourcefile variable hasn't expanded \..\, has included part of string , r can't process \..\

you can use for replaceable parameters resolve real path

for %%a in ("..\..\hcf_v9.r") set "rscript=%%~fa" 

Comments