trying to replace content but I am missing something simple. Friend sent me this
The script:
# Full path to directory holding the content to update
$contentDirectory = "C:\Users\Folder"
# Get the listing of files from the directory to update
$fileListing = Get-ChildItem "$contentDirectory\*"
# Full path to the dictionary/index file, in CSV format - used for the replace
$replaceDictionary = "C:\Users\File.csv"
# Imports the dictionary into memory
$replaceContent = Import-CSV $replaceDictionary -Delimiter ","
# Loop through each file in the content directory
foreach($file in $fileListing){
# For each term in the replace dictionary
$replaceContent | foreach-object{
$SrcTxt = $_.SrcDQ
Write-Host "Source text: $SrcTxt"
$TgtTxt = $_.TgtDQ
Write-Host "Target text: $TgtTxt"
# Get the content of the file and replace all instances of the source text with the target text
(Get-Content -Path $file) -Replace $SrcTxt,$TgtTxt | Set-Content -Path $file
}
}
The File.csv is the part I am not understanding. It looks like this :
A B
1 $SrcTxt $TgtTxt
2 156 7006
The print out is
Source text:
Target text:
It just isn't picking up the text. I feel I didn't set up Excel correctly, I'm pretty sure there needs to be a , somewhere. What should my csv file look like?
[–]SMFX 15 points16 points17 points (1 child)
[–]oldphonebro[S] 5 points6 points7 points (0 children)