title: How to pass several files to a command function and output them to different files?
body: <p>I have a directory made  of 50 files, here's an excerpt about how the files are names : </p>
  
  <pre><code>    input1.txt
      input2.txt    
      input3.txt
      input4.txt
  </code></pre>
  
  <p>I'm writing the script in R but I'm using bash commands inside it using "system"
  I have a system command X that takes one file and outputs it to one file
  example : </p>
  
  <pre><code>X input1.txt output1.txt
  </code></pre>
  
  <p>I want input1.txt to output to output1.txt, input2.txt to output to output2.txt etc..</p>
  
  <p>I've been trying this:</p>
  
  <pre><code>    for(i in 1:50)
      {
       setwd("outputdir");
       create.file(paste("output",i,".txt",sep=""));
       setwd("homedir");
       system(paste("/usr/local/bin/command" , paste("input",i,".txt",sep=""),paste("/outputdir/output",i,".txt",sep="")));
      }
  </code></pre>
  
  <p>What am I doing wrong? I'm getting an error at the line of system  , it says incorrect string constant , I don't get it.. Did I apply the system command in a wrong manner?</p>
  
  <p>Is there a way to get all the input files and output files without going through the paste command to get them inside system?</p>