| import os |
| import shutil |
| from pathlib import Path |
|
|
| def reconstruct_split_folders(*part_paths, output_dir="reconstructed"): |
| """ |
| Reconstruct split folders from multiple parts. |
| |
| Args: |
| *part_paths: Variable number of paths to the unzipped part folders |
| output_dir: Directory where the reconstructed structure will be created |
| """ |
| |
| os.makedirs(output_dir, exist_ok=True) |
|
|
| for part_path in part_paths: |
| |
| part_dir = Path(part_path) |
|
|
| |
| try: |
| first_subdir = next(p for p in part_dir.iterdir() if p.is_dir()) |
| except StopIteration: |
| print(f"No subdirectories found in {part_path}") |
| continue |
|
|
| |
| for root, _, files in os.walk(first_subdir): |
| for file in files: |
| |
| src_path = os.path.join(root, file) |
|
|
| |
| rel_path = os.path.relpath(src_path, first_subdir) |
|
|
| |
| dst_path = os.path.join(output_dir, rel_path) |
|
|
| |
| os.makedirs(os.path.dirname(dst_path), exist_ok=True) |
|
|
| |
| shutil.copy2(src_path, dst_path) |
| print(f"Copied: {rel_path}") |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| reconstruct_split_folders( |
| "/home/vfourel/SOCmapping/Data/Coordinates-20241211T155342Z-001", |
| "/home/vfourel/SOCmapping/Data/Coordinates-20241211T155342Z-002", |
| output_dir="/home/vfourel/SOCmapping/Data/Coordinates" |
| ) |
|
|
|
|