rbatch-fileserial-processing

Running multiple batch files serially using R?


I'm trying to run multiple batch files using a loop in R using the code below

for(i in 1:bfile)
{
  setwd(dpv[i])
  shell.exec("batcode.bat")
}

This loop calls all the batch files but what I want is to wait for one batch file to execute first before the next one gets called.

Is there a function which stops the R from proceeding before the previous commands get completed/executed.

Any help will be appreciated


Solution

  • I achieved this by changing

    shell.exec("batcode.bat") to shell("batcode.bat", wait=TRUE)