有的 很多 Search and Replace就可以
伦敦鹰 发表于 2026-3-15 11:08
这个论坛的元老,脑子堪比小学生
把你的需求提交给AI,五秒给你答案,豆包给你的答案
• # 配置
• $rootDir = "D:\your_txt_files"
• $target = "豆包"
• $url = "https://www.doubao.com"
• $replace = "<a href=`"$url`">$target</a>" # 注意转义双引号
•
• # 递归替换所有TXT
• Get-ChildItem -Path $rootDir -Filter *.txt -Recurse | ForEach-Object {
• $content = Get-Content $_.FullName -Raw -Encoding UTF8
• $newContent = $content -replace [regex]::Escape($target), $replace
• Set-Content $_.FullName -Value $newContent -Encoding UTF8
• Write-Host "处理: $($_.FullName)"
• }