LoginSignup
0
1

More than 5 years have passed since last update.

複数のHTMLファイルで単語の置換

Last updated at Posted at 2017-11-15

したいこと:
複数の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/

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1