到目前为止,我写了这篇文章,它贯穿始终,完全符合我的要求,现在我被困住了。我似乎无法打开新创建的$ NOSPACE.shtml并用变量$ SPACE替换一个单词。请帮助一点?
$CITYLIST=import-csv CityList.txt
$CITYLIST | FOREACH-OBJECT { $_ }
FOREACH ($Item in $CITYLIST) {
$Item.City
$NOSPACE=$Item.City.replace(" ","_")
$SPACE=$Item.City
Add-Content _citylist.shtml "`n<a class=`"cityareaslist`" href=`"`/$NOSPACE.shtml`"> $SPACE<`/a>" ; Copy-Item index.shtml "$NOSPACE.shtml"
}
答案 0 :(得分:0)
(Get-Content "$NOSPACE.shtml") |
Foreach-Object {$_ -replace 'word',$SPACE} |
Set-Content "$NOSPACE.shtml"