$files = Get-ChildItem -path C:\Data\ -filter *.txt foreach ($file in $files) { $content = Get-Content $file if ($content -match "99999999") { $content = $content -replace "99999999", $file.BaseName Set-Content $file $content } }
C:\Data\
C:\Windows\System32\
Get-ChildItem
-Force
Get-Content
$i = 10000000 foreach ($file in $files) { $content = Get-Content $file if ($content -match "99999999") { $content = $content -replace "99999999", $i++ Set-Content $file $content } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)