开发者

replacing string in many many .php files

i have downloaded a website i have created and want to find the domain name and replace it with a new one without having to open each file.

I use EditPlus

Is there any editor that can do this or do you know how to do this in windows or e开发者_JS百科ditplus?

thx


I'd suggest Notepad++. It has search and replace across one file, all open files, or all files in a directory.


You can do this in powershell.

$textToRemove = New-Object System.Text.RegularExpressions.Regex "SOMEREGEX", SingleLine

Get-Item "*.php" | ForEach-Object {
    $backupfile = [System.IO.File]::Copy($_.FullName,"NEWPATH")
    $text = [System.IO.File]::ReadAllText($_.FullName)
    $text = $textToRemove.Replace($text, "REPLACEWITHTHIS")
    $newFile = [System.IO.File]::OpenWrite($_.FullName)
    $newFile.Write($text);
    $newFile.Close()
}

The above is untested code. Powershell is your friend for automating tasks like this.


Worst case scenario, you could go for a trial version of something like Dreamweaver.

That said, I believe that Notepad++ is capable of this.


I thought EditPlus has a "continue to the next file" button.

So Open all files press ctrl+F find: olddomain replace: newdomain

"Replace all"button and "continue to the next file" button.


You can also use Eclipse or Aptana to do this

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜