LoginSignup
1
0

More than 1 year has passed since last update.

分割、配列の削除、拡張子の削除を組み合わせてファイル名から必要な部分を取得するPowerShellコマンドレット

Posted at
$fileName = "example_file_name.txt"

# ファイル名を"_"で分割
$fileParts = $fileName -split '_'

# 最初の配列を削除
$fileParts = $fileParts[1..($fileParts.Count - 1)]

# 拡張子を削除
$fileParts[-1] = $fileParts[-1] -replace "\.[^.]+$", ""

# 必要な部分を取得
$result = $fileParts -join "_"

# 結果を表示
Write-Output $result
1
0
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
0