Revision: 8156
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 4, 2008 11:58 by dreamlusion
Initial Code
function Replace-String($find, $replace, $path) { echo "Replacing string `"$find`" with string `"$replace`" in file contents and file names of path: $path" ls $path | select-string $find -list |% { echo "Processing contents of $($_.Path)"; (get-content $_.Path) |% { $_ -replace $find, $replace } | set-content $_.Path -Force } ls $path\*$find* |% { echo "Renaming $($_.FullName) to $($_.FullName.Replace($find, $replace))";mv $_.FullName $_.FullName.Replace($find, $replace) } } # Example Replace-String "Temp1" "Temp2" "D:\Temp"
Initial URL
Initial Description
Initial Title
Replace String in file contents and file names using PowerShell
Initial Tags
Initial Language
Windows PowerShell