Created
November 3, 2022 14:19
-
-
Save kateliev/e1e6541e33d171a08cde238773d702aa to your computer and use it in GitHub Desktop.
Overwrite multiple files residing in multiple folders with a single one
This file contains 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
# 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