File size: 763 Bytes
e8cce5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os

def create_mirror_structure(source_dir, target_dir):
    # 
    if not os.path.exists(source_dir):
        raise ValueError(f"Source directory {source_dir} does not exist.")
    
    # 
    for root, dirs, files in os.walk(source_dir, topdown=False):
        # 
        for dir in dirs:
            relative_path = os.path.relpath(os.path.join(root, dir), source_dir)
            # 
            target_subdir = os.path.join(target_dir, relative_path)
            if not os.path.exists(target_subdir):
                os.makedirs(target_subdir)

# 
source_directory = '/mnt/RHLH-LVMs/Dataset_Demo/Town_demo_house'  # 
target_directory = '/mnt/RHLH-LVMs/Dataset_Demo/Town_demo_house_copy'  # 

create_mirror_structure(source_directory, target_directory)