Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-07-18 23:17:44

0001 import os
0002 import shutil
0003 import argparse
0004 
0005 def copy_directory_content(src, dest):
0006     """
0007     Copies all content from the source directory to the destination directory.
0008     """
0009     if not os.path.exists(dest):
0010         os.makedirs(dest)
0011     
0012     for item in os.listdir(src):
0013         src_path = os.path.join(src, item)
0014         dest_path = os.path.join(dest, item)
0015         
0016         if os.path.isdir(src_path):
0017             shutil.copytree(src_path, dest_path)
0018         else:
0019             shutil.copy2(src_path, dest_path)
0020 
0021 def main():
0022     parser = argparse.ArgumentParser(description='Copy contents of a directory to a specified target directory.')
0023     parser.add_argument('target_directory', type=str, help='The target directory where content will be copied.')
0024     
0025     args = parser.parse_args()
0026     
0027     current_directory = os.path.dirname(os.path.abspath(__file__))  # Get the directory where the script is located
0028     target_directory = args.target_directory
0029     
0030     copy_directory_content(current_directory, target_directory)
0031     print(f"All content from {current_directory} has been copied to {target_directory}")
0032 
0033 if __name__ == "__main__":
0034     main()