Skip to content

Instantly share code, notes, and snippets.

@TakamiChie
Created March 3, 2025 07:54
Show Gist options
  • Select an option

  • Save TakamiChie/0acf3fc98692c96816c63145cb57c0b1 to your computer and use it in GitHub Desktop.

Select an option

Save TakamiChie/0acf3fc98692c96816c63145cb57c0b1 to your computer and use it in GitHub Desktop.
複数日のLISTEN文字起こしファイルをまとめて、一つのmarkdownファイルを作成するツール(拡張子がtxtなのは、mdだと読み込まないAIがあるため)
param(
[string]$dir
)
# カレントフォルダ内の対象ファイルを取得
$files = Get-ChildItem -Path $dir -Filter "*.txt" | Where-Object { $_.Name -match "^(\d{8})_(.+)\.txt$" }
# 出力ファイルのパス
$outputFile = "${dir}_summary.txt"
# 出力ファイルを初期化
"" | Set-Content $outputFile
# 各ファイルを処理
foreach ($file in $files) {
# ファイル名から日付とタイトルを抽出
if ($file.Name -match "^(\d{8})_(.+)\.txt$") {
$date = $matches[1] # yyyymmdd
$title = $matches[2] # ポッドキャストタイトル
# 日付をyyyy-mm-dd形式に変換
$formattedDate = "{0}-{1}-{2}" -f $date.Substring(0,4), $date.Substring(4,2), $date.Substring(6,2)
# ファイル内容を読み込む
$content = Get-Content $file.FullName -Raw
# Markdown形式で書き込む
"# $formattedDate $title`r`n$content`r`n" | Add-Content $outputFile
}
}
Write-Host "Markdownファイルが作成されました: $outputFile"
@TakamiChie
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment