renaming files in a directory using python or R -


i went across similar questions of renaming files in directory using python.

i have these files in directory want rename:

    -statistical_analysis_with_r     -statistical_pattern_recognition_3rd_edition      -statistical analysis r     -statistical pattern recognition 3rd edition 

for wrote script in windows:

def naming(so):     import re     w=re.split('[ _]+',so)     r=[]     in w:         r.append(i.capitalize())     print(' '.join(r))      import os c in os.listdir(os.getcwd()):     if c.endswith(".pdf"):         os.rename(c,naming(c)) print(os.listdir(os.getcwd())) 

but getting error:

statistical analysis r.pdf traceback (most recent call last):    file "<ipython-input-79-d7f645d6d3e5>", line 4, in <module>     os.rename(c,naming(c))  typeerror: rename: can't specify none path argument 

can what's going on?

and doing same thing using r (www.r-project.org)? 

loads of in advance.

your naming function doesn't return name, prints out name , returns none. that's why you're getting error none.

change this: print(' '.join(r))

to this: return ' '.join(r)


Comments

  1. I think SonarQube is one of the top java programming software tools. It offers support through Java 16 and helps in ORMs and Java frameworks. SonarQube also offers guidelines and rules for regular expression correctness and robustness that are unique in the industry. Integrations with Maven, Gradle, and common CIs make analysis easy.

    ReplyDelete

Post a Comment

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

html - Is there any way to exclude a single element from the style? (Bootstrap) -

Delphi 7 and decode UTF-8 base64 -