Posted By Poshoholic on 07 Oct 2009 08:53 PM
Something like this should do the trick:
Get-ChildItem -LiteralPath $rootFolder -Filter *SalesDB*.sql -Recurse -Force | Where-Object {-not $_.PSIsContainer} | Rename-Item -NewName {$_.Name -replace 'SalesDB','ProfileDB'}
Thanks for the reply.
I wrote this script, it will replace strings in a .sql file and replace it with another string literal. At the moment, I need to place this in every folder and call the powershell script, I am looking for a way where I can have one script, provide it with a folder path and the script will loop through all folders and sub-folders.
ls -recurse -filter *.sql |% { $text = (get-content $_.FullName) -replace "USE CompanyDB", "USE ProfileDB "; $text | out-file -encoding utf8 $_.FullName }