title: script to convert a sav file to csv and rename it as original file
body: <p>I have a script that converts a sav file to csv using R. The challenge is I want the output file name to be same as the filename passed as parameter with .csv extension</p>
  
  <p>syntax is: R-Script.sh  abc.sav</p>
  
  <p>The output file name should be abc.csv</p>
  
  <p>Here is the R code</p>
  
  <pre><code>argv &lt;- commandArgs(TRUE)
  Datafile &lt;- argv[1]
  library(foreign)
  dataSPSS &lt;- read.spss(Datafile, to.data.frame=TRUE)
  dim(dataSPSS)
  write.table(dataSPSS, file = "ifilename.csv", append = TRUE, quote = FALSE, sep = "|",eol = "\n", na = "", dec = ".", row.names = FALSE,col.names = TRUE, qmethod = c("escape", "double"))'
  </code></pre>
  
  <p>and the wrapper which is calling the R code:</p>
  
  <pre><code>DataFile=$1
  Rscript convert_sav-csv.r $DataFile
  mv ifilename.csv $DataFile.csv '
  </code></pre>
  
  <p>The output filename is something abc.sav.csv. and I want it to be abc.csv</p>