[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. <#*,:&cls
  2. @echo off
  3. cd /d "%~dp0"
  4. powershell -C "Set-Location -LiteralPath ([Environment]::CurrentDirectory);. ([ScriptBlock]::Create((Get-Content -LiteralPath \"%~f0\" -ReadCount 0 | Out-String)))"
  5. pause
  6. exit /b
  7. #>
  8. $arrFiles = "123.txt", "23.txt", "3000.txt"
  9. foreach ($itemFile in $arrFiles) {
  10.   try {
  11.     $basename = [system.io.path]::GetFileNameWithoutExtension($itemFile)
  12.     $ext = [System.IO.Path]::GetExtension($itemFile)
  13.     $psoList = (Get-Content -ReadCount 0 -LiteralPath $itemFile -ErrorAction Stop) | Select-Object -Property @{
  14.       Name       = 'Line'
  15.       Expression = { $_ }
  16.     }, @{
  17.       Name       = 'Field2'
  18.       Expression = { ($_ -split '_')[1] }
  19.     }
  20.     $psoList | Sort-Object -Property @{
  21.       Expression = {
  22.         $_.Field2.Length
  23.       }
  24.       Ascending  = $true
  25.     }, @{
  26.       Expression = {
  27.         $_.Field2
  28.       }
  29.       Ascending  = $false
  30.     } | Select-Object -ExpandProperty Line | Set-Content -LiteralPath "${basename}-1${ext}"
  31.     $psoList | Sort-Object -Property @{
  32.       Expression = {
  33.         $_.Field2.Length
  34.       }
  35.       Ascending  = $false
  36.     }, @{
  37.       Expression = {
  38.         $_.Field2
  39.       }
  40.       Ascending  = $true
  41.     } | Select-Object -ExpandProperty Line | Set-Content -LiteralPath "${basename}-a${ext}"
  42.     $psoList | Sort-Object -Property @{
  43.       Expression = {
  44.         $_.Field2.Length
  45.       }
  46.       Ascending  = $false
  47.     }, @{
  48.       Expression = {
  49.         $_.Field2
  50.       }
  51.       Ascending  = $false
  52.     } | Select-Object -ExpandProperty Line | Set-Content -LiteralPath "${basename}-z${ext}"
  53.   } catch {}
  54. }
复制代码
1

评分人数

微信:flashercs
QQ:49908356

TOP

返回列表