23 lines
719 B
Python
23 lines
719 B
Python
import shutil
|
|
import os
|
|
|
|
try:
|
|
source_dir = '.'
|
|
destination_dir = 'ver1_ext'
|
|
|
|
# Ensure destination directory exists and is empty
|
|
if os.path.exists(destination_dir):
|
|
shutil.rmtree(destination_dir)
|
|
os.makedirs(destination_dir)
|
|
|
|
# Copy contents of source_dir to destination_dir
|
|
for item in os.listdir(source_dir):
|
|
s = os.path.join(source_dir, item)
|
|
d = os.path.join(destination_dir, item)
|
|
if os.path.isdir(s):
|
|
shutil.copytree(s, d, dirs_exist_ok=True)
|
|
else:
|
|
shutil.copy2(s, d)
|
|
print(f"Successfully copied contents of {source_dir} to {destination_dir}")
|
|
except Exception as e:
|
|
print(f"An error occurred during copying: {e}") |