I have been looking for solutions for a while but no luck. I apologise if this has already been solved.
Trying to rename file extensions from.ods to.xls across all files in a directory:
import os
def Convert(dirpath):
for ws in os.listdir(dirpath):
splitfile = os.path.splitext(ws)
os.rename(ws, splitfile[0] + '.xls')
Convert('my_directory')
This returns the error: FileNotFoundError: [WinError 2] The system cannot find the file specified: 'filename_that_exists.ods' -> 'filename_that_exists.xls'
Try this might solve your problem
os.rename(os.path.join(directory,name),
os.path.join(directory,'0'+name))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.