powershell:落書き
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン | |||
powershell:落書き [2023/09/05 10:24] – 133.106.218.227 | powershell:落書き [2024/05/13 06:50] (現在) – 133.106.206.103 | ||
---|---|---|---|
行 112: | 行 112: | ||
< | < | ||
+ | # 入力ファイルパス | ||
+ | $inputPath = " | ||
+ | # 出力ファイルのベースパス | ||
+ | $outputBasePath = " | ||
+ | |||
+ | # ファイルを開いて読み込む | ||
+ | $reader = [System.IO.StreamReader]:: | ||
+ | |||
+ | # 変数の初期化 | ||
+ | $lineCount = 0 | ||
+ | $fileIndex = 1 | ||
+ | $content = New-Object System.Collections.Generic.List[string] | ||
+ | |||
+ | try { | ||
+ | while ($null -ne ($line = $reader.ReadLine())) { | ||
+ | # 行をリストに追加 | ||
+ | $content.Add($line) | ||
+ | $lineCount++ | ||
+ | |||
+ | # 10000行ごとにファイルに書き出す | ||
+ | if ($lineCount -eq 10000) { | ||
+ | $outputPath = " | ||
+ | [System.IO.File]:: | ||
+ | # 変数をリセット | ||
+ | $content.Clear() | ||
+ | $lineCount = 0 | ||
+ | $fileIndex++ | ||
+ | } | ||
+ | } | ||
+ | |||
+ | # 最後のファイル(10000行未満の場合) | ||
+ | if ($content.Count -gt 0) { | ||
+ | $outputPath = " | ||
+ | [System.IO.File]:: | ||
+ | } | ||
+ | } | ||
+ | finally { | ||
+ | $reader.Close() | ||
+ | } | ||
+ | |||
</ | </ | ||
powershell/落書き.1693909441.txt.gz · 最終更新: 2023/09/05 10:24 by 133.106.218.227