LoginSignup
1
3

More than 5 years have passed since last update.

1行で書けるPowerShellスクリプト -エンコード編-

Last updated at Posted at 2019-02-20

はじめに

PowerShellのコマンドレットを活用してファイル単位でのエンコーディング操作を行います。

こんな場合に使用します

受け取ったファイルのエンコーディングが想定と異なり文字化けする。
古くからのサーバなどで自動生成されているファイルが「Shitf-JIS」形式などで
 別システムへのデータ連携(UTF8)においてエンコード変換が必要となる。

コード

Get-Content [コピー元 File-Path] | Set-Content [コピー先 File-Path] -Encoding UTF8

※注:(コピー元)と(コピー先)を同一にすると「Read/Write Lock」がかかります。

最後に

上記コマンドレットをスクリプト(拡張子ps1ファイル)として保存することでバッチ処理に活用できます。

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