update the script to show the progress of the file transfer. import os import shutil def…
- User
update the script to show the progress of the file transfer.
import os import shutil
def copy_missing_files(wsl_dir, windows_dir): """ Copy files that exist in wsl_dir but not in windows_dir.
code:param wsl_dir: Path to WSL directory :param windows_dir: Path to Windows directory """ wsl_dir = os.path.abspath(wsl_dir) windows_dir = os.path.abspath(windows_dir) for root, dirs, files in os.walk(wsl_dir): for file in files: wsl_file_path = os.path.join(root, file) # Compute relative path from wsl_dir root rel_path = os.path.relpath(wsl_file_path, wsl_dir) windows_file_path = os.path.join(windows_dir, rel_path) # Check if file exists in windows_dir if not os.path.exists(windows_file_path): windows_file_dir = os.path.dirname(windows_file_path) # Create destination directory if it does not exist if not os.path.exists(windows_file_dir): os.makedirs(windows_file_dir) print(f"Copying missing file: {rel_path}") shutil.copy2(wsl_file_path, windows_file_path)if name == "main": # Example usage # Using WSL path in Windows format, e.g. \wsl$\Ubuntu\home\user\folder # Or you can access WSL files from WSL python and copy to mounted Windows folder, e.g. /mnt/c/...
codewsl_directory = r'\\wsl$\Ubuntu\home\meow\fish-speech' # Change this to your WSL directory windows_directory = r'D:\fish-speech' # Change this to your Windows directory copy_missing_files(wsl_directory, windows_directory) print("Done copying missing files.") - Assistant
To show the progress of the file transfer, you can update the script to track how many files it will copy, then update the user as each file is copied.