Created
March 3, 2025 07:54
-
-
Save TakamiChie/0acf3fc98692c96816c63145cb57c0b1 to your computer and use it in GitHub Desktop.
複数日のLISTEN文字起こしファイルをまとめて、一つのmarkdownファイルを作成するツール(拡張子がtxtなのは、mdだと読み込まないAIがあるため)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
元になったAI問答:https://takamichie.notion.site/PowerShell-1ab60d1e6e7980849066cb88f239ef56?pvs=4