[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

【已解决】【30元红包】批处理csv文件降序排

本帖最后由 linfeng_321 于 2022-3-30 18:05 编辑

根目录\文档\记录.csv
批处理脚本:放根目录
------------------------------------------------
原始:记录.csv,文件内容如下:
---------------
"本机当前用户名","本机IP地址","编号","名称","作者","版本","开始时间","结束时间","当前状态","制作次数"
"123","192.168.1.97","1222211249","名称6","老六","9","2022-03-30 15:10:14","","制作中","1"
"123","192.168.1.97","1222211248","名称5","老五","4","2022-03-24 15:20:59","","制作中","5"
"123","192.168.1.97","1222211247","名称4","老四","1","2022-03-13 15:20:59","","制作中","2"
"123","192.168.1.97","1222211246","名称3","老三","7","2022-03-19 15:20:59","","制作中","0"
"123","192.168.1.97","1222211245","名称2","老二","2","2022-03-30 15:25:58","","制作中","1"
"123","192.168.1.97","1222211244","名称1","老大","3","2022-03-21 13:20:51","","制作中","9"
------------------------------------------------
以“开始时间”降序排
------------------------------------------------
修改后:记录.csv,文件内容如下:
---------------
"本机当前用户名","本机IP地址","编号","名称","作者","版本","开始时间","结束时间","当前状态","制作次数"
"123","192.168.1.97","1222211245","名称2","老二","2","2022-03-30 15:25:58","","制作中","1"
"123","192.168.1.97","1222211249","名称6","老六","9","2022-03-30 15:10:14","","制作中","1"
"123","192.168.1.97","1222211248","名称5","老五","4","2022-03-24 15:20:59","","制作中","5"
"123","192.168.1.97","1222211244","名称1","老大","3","2022-03-21 13:20:51","","制作中","9"
"123","192.168.1.97","1222211246","名称3","老三","7","2022-03-19 15:20:59","","制作中","0"
"123","192.168.1.97","1222211247","名称4","老四","1","2022-03-13 15:20:59","","制作中","2"

  1. <# :
  2. cls&echo off&cd /d "%~dp0"&rem 编码ANSI
  3. powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
  4. pause
  5. exit
  6. #>
  7. $csvfile=".\记录.csv";
  8. if(-not (test-path -literal $csvfile)){write-host ('"'+$csvfile+'" 未找到');exit;}
  9. $enc=[Text.Encoding]::GetEncoding('UTF-8');
  10. $text=[IO.File]::ReadAllLines($csvfile, $enc);
  11. if($text.count -ge 3){
  12.     $arr=@($text[1..($text.count -1)]|sort {$_.split(',')[6]} -Descending);
  13.     $newtext=$text[0]+"`r`n"+($arr -join "`r`n");
  14.     [IO.File]::WriteAllText($csvfile, $newtext, $enc);
  15. }
复制代码
提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表