LoginSignup
1
1

More than 3 years have passed since last update.

(Powershell) ファイル内の文字列を置換してコピーするスクリプト

Posted at

ディレクトリ内のファイルを読み込んで文字列を置換したコピーを作成するスクリプト

Get-ChildItem .\ | ForEach-Object{
$target = $_
echo $target
Get-Content $target | %{$_ -ireplace "from", "to"} > .\20190926\$target
}

対象ファイル内の文字列を置換してコピーを作成する

Get-Content .\FromFile.txt | %{$_ -ireplace "from1", "to1"} | %{$_ -ireplace "from2","to2"} > .\20190926\ToFile.txt

参照

下記のサイトにファイルの文字列置換についての記述を参考にさせて頂きました。
https://qiita.com/mindwood/items/66207426904d02bd3359

以上です。

1
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
1
1