Поместите приведенный ниже скрипт в файл PowerShell .ps1.
$data = @(
@{
pattern = "LACTION 'SQL\(''logility_prod_scp_logility'',"
replacement = "LACTION 'SQL(''LOGILITY_PROD_SCP_LOGILITY'',"
inputFile = "C:\files\DW_FEI_input.ctg"
outPutFile = "C:\files\DW_FEI_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''dwfei'',"
replacement = "LACTION 'SQL(''DW_FEI'',"
inputFile = "C:\files\DW_FEI_input.ctg"
outPutFile = "C:\files\DW_FEI_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''DWFEI'',"
replacement = "LACTION 'SQL(''DW_FEI'',"
inputFile = "C:\files\DW_FEI_input.ctg"
outputFile = "C:\files\DW_FEI_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''DWFEI'',"
replacement = "LACTION 'SQL(''DW_FEI'',"
inputFile = "C:\files\SALES_MART_input.ctg"
outPutFile = "C:\files\SALES_MART_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''dwfei'',"
replacement = "LACTION 'SQL(''DW_FEI'',"
inputFile = "C:\files\SALES_MART_input.ctg"
outPutFile = "C:\files\SALES_MART_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''user_shared'',"
replacement = "LACTION 'SQL(''USER_SHARED'',"
inputFile = "C:\files\SALES_MART_input.ctg"
outPutFile = "C:\files\SALES_MART_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''DW_FEI_PROD'',"
replacement = "LACTION 'SQL(''DW_FEI'',"
inputFile = "C:\files\SALES_MART_input.ctg"
outPutFile = "C:\files\SALES_MART_output.ctg"
},
@{
pattern = "LACTION'SQL\(''SALES_MART_PROD'',"
replacement = "LACTION 'SQL(''SALES_MART'',"
inputFile = "C:\files\SALES_MART_input.ctg"
outPutFile = "C:\files\SALES_MART_output.ctg"
},
@{
pattern = "LACTION 'SQL\(''sales_mart'',"
replacement = "LACTION 'SQL(''SALES_MART'',"
inputFile = "C:\files\SALES_MART_input.ctg"
outPutFile = "C:\files\SALES_MART_output.ctg"
}
)
$data |
ForEach-Object {
(Get-Content $_.inputFile) -replace $_.pattern, $_.replacement | Out-File $_.outputFile
}
Редактировать
Флаг --Append
должен присутствовать на Out-File
.
$data |
ForEach-Object {
(Get-Content $_.inputFile) -replace $_.pattern, $_.replacement | Out-File $_.outputFile --append
}
Редактировать
Если вы не знакомы с PowerShell, самый простой способ запустить этот скрипт - выполнить следующие шаги.
- Скопируйте / вставьте скрипт PowerShell в файл с именем
script.ps1
. Скопируйте / вставьте содержимое ниже в файл с именем runscript.cmd
.
@echo off
SET psfile="%~dp0script.ps1"
PowerShell.exe -ExecutionPolicy ByPass -File %psfile%
pause
Выполнить runscript.cmd
из командной строки.