したいこと:
複数のHTMLファイルで単語の置換
ポイント:
% は foreach のエイリアス
ls は gci(get-childItem)でも同じ。
①Z01から始まるファイルでのみ、[Z010]を[W050]に置き換えて、同じフォルダ内に別の名前で保存
PS> ls -n Z01*.html | %{\$fname="new_"+$_;cat $_ | %{\$_ -replace "Z010","W050" >> $fname}}
②Z01から始まるファイルでのみ、[Z010]を[W050]に置き換えて、同じフォルダの中の[BK]フォルダに別の名前で保存
PS> ls -n Z01*.html | %{\$fname="BK\\"+"new_"+$_;cat $_ | %{\$_ -replace "Z010","W050" >> $fname}}
※以下からカンコピです。ありがとうございました。
https://life-is-command.com/powershell-replace-files-to-folders/