«

[PowerShell] ファイル分割スクリプト

大きなファイルを分割する必要があって
めっちゃ困りましたけど、また PowerShell で解決しました
なかばやけくそ

<sep.ps1>

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
$my_path_name = "c:/tmp/"
$my_file_name = "abc"
$my_file_kind = ".log"
$cut_num      = 2000    # 切り取る行数

$my_file = $my_path_name + $my_file_name + $my_file_kind

$count = 0;
Get-Content $my_file -ReadCount $cut_num -Encoding UTF8 | 
    ForEach-Object { 
        $count ++
        $cfs = "{0:D3}" -f $count;
        $_ > ($my_path_name+$my_file_name+'_'+$cfs+$my_file_kind)
    }

結果

あまり何も考えず、元ネタはこの方のブログですー

comments powered by Disqus