Created
July 29, 2023 10:57
-
-
Save ZipFile/63819d21933e490ad794c39f7e22ddea to your computer and use it in GitHub Desktop.
Link AUTOMATIC1111/stable-diffusion-webui models to ComfyUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Creating symbolic/hard link is prohibited by default. | |
# To run this script you need either: | |
# * Have an Administrator permissions | |
# * Enabled Developer Mode | |
# * Configured Create symbolic links policy | |
# Also do not forget that running ps1 scripts is also prohibited by default. | |
# If you're lazy as fuck, just copy-paste everything below into PowerShell console. | |
Set-StrictMode -Version Latest | |
$ErrorActionPreference = "Stop" | |
# Edit these: | |
$srcRoot = "$env:USERPROFILE\Pictures\AI\sd.webui\webui" | |
$dstRoot = "$env:USERPROFILE\Pictures\AI\ComfyUI_windows_portable\ComfyUI" | |
$dirs = @{ | |
"embeddings" = "models\embeddings"; | |
"models\ControlNet" = "models\controlnet"; | |
"models\ESRGAN" = "models\upscale_models"; | |
"models\Lora" = "models\loras"; | |
"models\LyCORIS" = "models\loras"; | |
"models\RealESRGAN" = "models\upscale_models"; | |
"models\Stable-diffusion" = "models\checkpoints"; | |
"models\VAE" = "models\vae"; | |
# "models\VAE-approx" = "models\vae_approx"; | |
"models\hypernetworks" = "models\hypernetworks"; | |
} | |
$include = "*.safetensors" , "*.ckpt", "*.pt", "*.pth" | |
$hardlink = $false | |
# Do not touch: | |
$linkType = if ($hardlink) { "HardLink" } else { "SymbolicLink" } | |
foreach ($dir in $dirs.GetEnumerator()) { | |
$srcDir = $dir.Key | |
$dstDir = $dir.Value | |
$path = [IO.Path]::Combine($srcRoot, $srcDir) | |
$fileNames = Get-ChildItem $path -Recurse -Include $include -Name | |
foreach ($fileName in $fileNames) { | |
$source = [IO.Path]::Combine($srcRoot, $srcDir, $fileName) | |
$target = [IO.Path]::Combine($dstRoot, $dstDir, $fileName) | |
if ([System.IO.File]::Exists($target)) { | |
"File $target exists, skipping" | |
} else { | |
"$linkType $source -> $target" | |
$null = New-Item -ItemType $linkType -Path $target -Target $source | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment