- <# :
- cls&echo off&cd /d "%~dp0"&rem 编码ANSI
- powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
- pause
- exit
- #>
- $csvfile=".\记录.csv";
- if(-not (test-path -literal $csvfile)){write-host ('"'+$csvfile+'" 未找到');exit;}
-
- $enc=[Text.Encoding]::GetEncoding('UTF-8');
- $text=[IO.File]::ReadAllLines($csvfile, $enc);
- if($text.count -ge 3){
- $arr=@($text[1..($text.count -1)]|sort {$_.split(',')[6]} -Descending);
- $newtext=$text[0]+"`r`n"+($arr -join "`r`n");
- [IO.File]::WriteAllText($csvfile, $newtext, $enc);
- }
复制代码
|