From ef85b642398121823e18fea19aa652894c9fc171 Mon Sep 17 00:00:00 2001 From: Shubham Rathi Date: Tue, 17 Jan 2017 12:14:45 +0530 Subject: [PATCH] fixing a bug in 'batch_rename' --- batch_file_rename.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/batch_file_rename.py b/batch_file_rename.py index d2262933443..581d162cbc0 100644 --- a/batch_file_rename.py +++ b/batch_file_rename.py @@ -24,8 +24,11 @@ def batch_rename(work_dir, old_ext, new_ext): file_ext = os.path.splitext(filename)[1] # Start of the logic to check the file extensions, if old_ext = file_ext if old_ext == file_ext: - # Set newfile to be the filename, replaced with the new extension - newfile = filename.replace(old_ext, new_ext) + # Returns changed name of the file with new extention + name_list=list(filename) + name_list[len(name_list)-len(old_ext):]=list(new_ext) + newfile=''.join(name_list) + # Write the files os.rename( os.path.join(work_dir, filename),