This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import shutil | |
| try: | |
| # This function handle duplicate files | |
| def handle_duplicate_file(dst, directory_name, file_name, counter): | |
| name, ext=os.path.splitext(file_name) # Split file name extension in list as `["file_name", ".png"]` | |
| new_file_name=f"{file_name}_{counter}{ext}" | |
| return os.path.join(dst, directory_name, new_file_name) |