Life and Tech Talk

Chromadb copy code
def chromacopy(source_dir, destination_dir):
    if not os.path.exists(source_dir):
        print(f"The source directory '{source_dir}' does not exist.")
    else:
        if os.path.exists(destination_dir):
            for root, dirs, files in os.walk(destination_dir):
                for file in files:
                    os.remove(os.path.join(root, file))
                for dir in dirs:
                    shutil.rmtree(os.path.join(root, dir))
                    print(f"Cleared contents of directory '{destination_dir}'.")
    try:
        shutil.copytree(source_dir, destination_dir, dirs_exist_ok=True)
        print(f"Directory '{source_dir}' has been copied to '{destination_dir}'.")
    except Exception as e:
        print(f"An error occurred while copying the directory: {e}")
올린날: 2024년 7월 3일
주제: 코드 관련 포스팅 클릭!!

* 올린이: 마이클

* VIEW: 25       0           위키홈     게시판     수정