本帖最后由 PowerShell 于 2013-7-13 22:42 编辑
我也来凑热闹了 用时,别忘了把f:\txt那块修改了,并把#给取消掉。并备份下源文件- foreach ($a in (Get-ChildItem f:\TXT\aaa\*.htm* -Recurse) )
- {
- $整个标题行 = Get-Content $a | select-string -list -Pattern "<title>.*</title>"
-
- if ($整个标题行 -ne $null)
- {
- $网页最终标题 = $整个标题行 -replace "^.*<title>",""
- $网页最终标题 = $网页最终标题 -replace "</title>.*$",""
- write-host $a.fullname,"---",$网页最终标题
- #Rename-Item $a $网页最终标题
- $整个标题行 = $null
- }
- else
- {
- Write-Warning $a.fullname
-
- }
-
-
-
- }
- #powershell好,语法简单,无需转义,特殊字符处理妙,
复制代码
|