Skip to content

Instantly share code, notes, and snippets.

@kateliev
Created November 3, 2022 14:19
Show Gist options
  • Save kateliev/e1e6541e33d171a08cde238773d702aa to your computer and use it in GitHub Desktop.
Save kateliev/e1e6541e33d171a08cde238773d702aa to your computer and use it in GitHub Desktop.
Overwrite multiple files residing in multiple folders with a single one
# SCRIPT: Replace a file in multiple paths
# NOTE: A very usefull too to force compatibility in UFO files by copying over the same layer design!
# VER: 1.1
# -----------------------------------------------------------
# (C) Vassil Kateliev, 2022 (http://www.kateliev.com)
#------------------------------------------------------------
# No warranties. By using this you agree
# that you use it at your own risk!
# - Take parameters from CLI
param (
[Parameter(Mandatory=$true)][string]$path,
[Parameter(Mandatory=$true)][string]$file
)
# - Init
$search_filename = Split-Path -Path $file -Leaf
$search = Get-ChildItem $path $search_filename -recurse
foreach ($dst_path in $search) {
Write-output "COPY >> $dst_path"
Copy-Item -Path $file -Destination $dst_path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment