remove files rather than overwrite
This commit is contained in:
parent
0b05c0ac38
commit
a53ecbf8f0
@ -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}")
|
||||
|
Loading…
Reference in New Issue
Block a user