From 8a6e98608f5f35e0c4ae16fe9daec0d868e5d5a8 Mon Sep 17 00:00:00 2001 From: dark Date: Tue, 24 Dec 2024 01:14:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- replaceTag.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 replaceTag.ps1 diff --git a/replaceTag.ps1 b/replaceTag.ps1 new file mode 100644 index 0000000..9febbf3 --- /dev/null +++ b/replaceTag.ps1 @@ -0,0 +1,15 @@ +# 接收4个参数,用于替换 参数1 文件中的 参数2:参数3 为 参数2:参数4 +param ( + [string]$filePath, + [string]$key, + [string]$oldValue, + [string]$newValue +) + +# 替换 $filePath 文件中的 $key:$oldValue 为 $key:$newValue +Write-Output "replace $filePath ${key}:$oldValue to ${key}:$newValue then save to $filePath" +(Get-Content $filePath) -replace "${key}:$oldValue", "${key}:$newValue" | Set-Content $filePath + +Get-Content $filePath + +