title: renaming files in a directory using python or R
body: <p>I went across similar questions of renaming files in a directory using python.</p>
  
  <p>I have these files in a directory which I want to rename:</p>
  
  <pre><code>    -statistical_analysis_with_r
      -statistical_pattern_recognition_3rd_edition
  </code></pre>
  
  <p>to</p>
  
  <pre><code>    -Statistical Analysis With R
      -Statistical Pattern Recognition 3rd Edition
  </code></pre>
  
  <p>For this I wrote this script in windows:</p>
  
  <pre><code>def naming(so):
      import re
      w=re.split('[ _]+',so)
      r=[]
      for i in w:
          r.append(i.capitalize())
      print(' '.join(r))  
  
  
  
  import os
  for c in os.listdir(os.getcwd()):
      if c.endswith(".pdf"):
          os.rename(c,naming(c))
  print(os.listdir(os.getcwd()))
  </code></pre>
  
  <p>But I am getting this error:</p>
  
  <pre><code>Statistical Analysis With R.pdf
  Traceback (most recent call last):
  
    File "&lt;ipython-input-79-d7f645d6d3e5&gt;", line 4, in &lt;module&gt;
      os.rename(c,naming(c))
  
  TypeError: rename: can't specify None for path argument
  </code></pre>
  
  <p>Can anybody help what's going on?</p>
  
  <pre><code>And any help doing same thing using R (www.r-project.org)?
  </code></pre>
  
  <p>Loads of thanks in advance.</p>