python - shutil.move removing file extensions -
You guys were very helpful with my learning python I was tasked with modifying the code of an old staff And since then it has helped to download many resources. I'm changing the name of the files in a folder basically gives the user some information in a text box and which is being added at the end of the file.
if len (self.toLoc.get ()) == 0: searchRev = "_R" + oslistdir (App.pdfDir) for filename newreve: sep = searchesri rest = filename. Shutil.move (os.path.join (App.pdfDir, file name), OS path.join (App.pdfDir, comfort) from split (sep, 1) [0] + searchRev +) < / Pre> This works perfectly, I have only one issue that does not keep the file extension and unfortunately there are PDFs and XLSX is in DIR so I can not just do hard code PDF at the end . I tried to see that there was a way to get it in the OS function, but I was confusing myself ... "post-text" itemprop = "text">
I'm not sure what search is , but you're throwing a part of the file name into filename.split (sep, 1) [0] . Maybe you have to add filename.split (sep, 1) [1] at the end of your destination file name?
Comments
Post a Comment