diff --git a/user_updater.py b/user_updater.py index 72bc6c0..61778ff 100644 --- a/user_updater.py +++ b/user_updater.py @@ -15,6 +15,9 @@ def replace_word_in_files(target_word, replacement_word, folder_path=".", dest_p # Write the new content back to the file file_path = os.path.join(dest_path, filename) + if os.path.exists(file_path): + os.remove(dst_file) + with open(file_path, 'w') as file: file.write(new_content) @@ -29,7 +32,9 @@ def copy_png_files_up(): if filename.endswith(".png"): # Check if the file is a .png file source_path = os.path.join(current_dir, filename) destination_path = os.path.join(parent_dir, filename) - + if os.path.exists(destination_path): + os.remove(destination_path) + # Copy the .png file to the parent directory shutil.copy(source_path, destination_path) print(f"Copied: {filename} to {parent_dir}")