2016-04-11 9 views
-1

Ich habe eine Textdatei, die Text in der folgenden Form enthältText Sortierung in Windows

Name Surname: Group : Points 

Und ich möchte wissen, ob seine mögliche zuerst von den höchsten Punkten zu sortieren. Ich habe versucht, sort /+pos file.txt zu verwenden, aber es hat nicht funktioniert. Irgendwelche Ideen?

+0

Verwenden Sie ** wirklich ** MS-DOS oder beziehen Sie sich auf die Befehlszeile in Windows? –

+0

@a_horse_with_no_name Befehlszeile in Windows, sorry mein Fehler. – Dimitrios

+0

Haben Sie an der Eingabeaufforderung "Hilfe sortieren" eingegeben? –

Antwort

1

Windows Sortierung sortiert nur Text.

Set Arg = WScript.Arguments 
set WshShell = createObject("Wscript.Shell") 
Set Inp = WScript.Stdin 
Set Outp = Wscript.Stdout 
Set rs = CreateObject("ADODB.Recordset") 
If LCase(Arg(1)) = "n" then 
With rs 
    .Fields.Append "SortKey", 4 
    .Fields.Append "Txt", 201, 5000 
    .Open 
    Do Until Inp.AtEndOfStream 
     Lne = Inp.readline 
     SortKey = Mid(Lne, LCase(Arg(3)), LCase(Arg(4)) - LCase(Arg(3))) 
     If IsNumeric(Sortkey) = False then 
      Set RE = new Regexp 
      re.Pattern = "[^0-9\.,]" 
      re.global = true 
      re.ignorecase = true 
      Sortkey = re.replace(Sortkey, "") 
     End If 
     If IsNumeric(Sortkey) = False then 
      Sortkey = 0 
     ElseIf Sortkey = "" then 
      Sortkey = 0 
     ElseIf IsNull(Sortkey) = true then 
      Sortkey = 0 
     End If 
     .AddNew 
     .Fields("SortKey").value = CSng(SortKey) 
     .Fields("Txt").value = Lne 
     .UpDate 
    Loop 
    If LCase(Arg(2)) = "a" then SortColumn = "SortKey ASC" 
    If LCase(Arg(2)) = "d" then SortColumn = "SortKey DESC" 
    .Sort = SortColumn 
    Do While not .EOF 
     Outp.writeline .Fields("Txt").Value 
     .MoveNext 
    Loop 
End With 

ElseIf LCase(Arg(1)) = "d" then 
With rs 
    .Fields.Append "SortKey", 4 
    .Fields.Append "Txt", 201, 5000 
    .Open 
    Do Until Inp.AtEndOfStream 
     Lne = Inp.readline 
     SortKey = Mid(Lne, LCase(Arg(3)), LCase(Arg(4)) - LCase(Arg(3))) 
     If IsDate(Sortkey) = False then 
      Set RE = new Regexp 
      re.Pattern = "[^0-9\\\-:]" 
      re.global = true 
      re.ignorecase = true 
      Sortkey = re.replace(Sortkey, "") 
     End If 
     If IsDate(Sortkey) = False then 
      Sortkey = 0 
     ElseIf Sortkey = "" then 
      Sortkey = 0 
     ElseIf IsNull(Sortkey) = true then 
      Sortkey = 0 
     End If 
     .AddNew 
     .Fields("SortKey").value = CDate(SortKey) 
     .Fields("Txt").value = Lne 
     .UpDate 
    Loop 
    If LCase(Arg(2)) = "a" then SortColumn = "SortKey ASC" 
    If LCase(Arg(2)) = "d" then SortColumn = "SortKey DESC" 
    .Sort = SortColumn 
    Do While not .EOF 
     Outp.writeline .Fields("Txt").Value 
     .MoveNext 
    Loop 
End With 


ElseIf LCase(Arg(1)) = "t" then 
With rs 
    .Fields.Append "SortKey", 201, 260 
    .Fields.Append "Txt", 201, 5000 
    .Open 
    Do Until Inp.AtEndOfStream 
     Lne = Inp.readline 
     SortKey = Mid(Lne, LCase(Arg(3)), LCase(Arg(4)) - LCase(Arg(3))) 
     .AddNew 
     .Fields("SortKey").value = SortKey 
     .Fields("Txt").value = Lne 
     .UpDate 
    Loop 
    If LCase(Arg(2)) = "a" then SortColumn = "SortKey ASC" 
    If LCase(Arg(2)) = "d" then SortColumn = "SortKey DESC" 
    .Sort = SortColumn 
    Do While not .EOF 
     Outp.writeline .Fields("Txt").Value 
     .MoveNext 
    Loop 
End With 
ElseIf LCase(Arg(1)) = "tt" then 
With rs 
    .Fields.Append "SortKey", 201, 260 
    .Fields.Append "Txt", 201, 5000 
    .Open 
    Do Until Inp.AtEndOfStream 
     Lne = Inp.readline 
     SortKey = Trim(Mid(Lne, LCase(Arg(3)), LCase(Arg(4)) - LCase(Arg(3)))) 
     .AddNew 
     .Fields("SortKey").value = SortKey 
     .Fields("Txt").value = Lne 
     .UpDate 
    Loop 
    If LCase(Arg(2)) = "a" then SortColumn = "SortKey ASC" 
    If LCase(Arg(2)) = "d" then SortColumn = "SortKey DESC" 
    .Sort = SortColumn 
    Do While not .EOF 
     Outp.writeline .Fields("Txt").Value 
     .MoveNext 
    Loop 
End With 
End If 

Sort

filter Sort {n|d|t|tt} {a|d} startcolumn endcolumn 

sortiert eine Datei

n - extracts a number from the columns specified. Looks for the first number. 
d - extracts a time or date from the columns specified. Looks for the first date. 
t - extracts a text string including spaces from the columns specified. 
tt - extracts a text string discarding leading and trailing spaces from the columns specified. 

a - sorts acending 
d - sorts decending 

Startcolumn - die Anfangsspalte, das erste Zeichen der Spalte 1

EndColumn - die Endung Spalte

Beispiel

cscript //nologo filter sort n a 1 11 < "%windir%\win.ini" 

Filter liest und schreibt Standard in und Standard-out nur. Diese sind nur in einer Eingabeaufforderung verfügbar.

filter <inputfile >outputfile 
filter <inputfile | other_command 
other_command | filter >outputfile 
other_command | filter | other_command