first_project
This commit is contained in:
23
copy_project.py
Normal file
23
copy_project.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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}")
|
Reference in New Issue
Block a user