AHK 对文件列表进行反向排序
AHK Reverse sort on file list
我无法在列表中进行反向排序。我不明白如何按名称、最后修改时间或任何属性正确地对我的文件进行排序。
Gui, Add, Text, title?, Pick a file to launch from the list below.`nTo cancel, press ESCAPE or close this window.
Gui, Add, ListBox, vMyListBox gMyListBox w500 r5
Gui, Add, Button, Default, OK
Loop files, C:\Users\me\Downloads\*.png
{
FileList = %A_LoopFileName%
Sort, FileList, R ; Sort, reverse order.
GuiControl,, MyListBox, %FileList%
}
Gui, Show, w550 h140, hello
return
MyListBox:
if (A_GuiEvent != "DoubleClick")
return
ButtonOK:
GuiControlGet, MyListBox
GuiClose:
GuiEscape:
ExitApp
看起来我基本上是在循环中循环。或者我无法完全描述的错误。但是最好先画出列表,然后对其进行排序,然后像这样应用于 gui...
Gui, Add, Text, title?, Pick a file to launch from the list below.`nTo cancel, press ESCAPE or close this window.
Gui, Add, ListBox, vMyListBox gMyListBox w500 r5
Gui, Add, Button, Default, OK
FileList :=
Loop files, C:\Users\me\Downloads\*.png
{
FileList .= A_LoopFileName . "|"
}
Sort, FileList, R D| ; Sort, reverse order. Use '|' as the Delimiter.
GuiControl,, MyListBox, %FileList%
Gui, Show, w550 h140, hello
return
MyListBox:
if (A_GuiEvent != "DoubleClick")
return
ButtonOK:
GuiControlGet, MyListBox
GuiClose:
GuiEscape:
ExitApp
如果需要对上次修改或创建进行排序。您可以将其添加到列表中,同时在循环中构建它,然后在排序发生后使用 14 位数字上的正则表达式替换将其删除。
Gui, Add, Text, title?, Pick a file to launch from the list below.`nTo cancel, press ESCAPE or close this window.
Gui, Add, ListBox, vMyListBox gMyListBox w500 r5
Gui, Add, Button, Default, OK
FileList :=
Loop files, C:\Users\me\Downloads\*.png
{
FileList .= A_LoopFileTimeModified "," A_LoopFileName "|"
}
Sort, FileList, R D| ; Sort, reverse order. Use '|' as the Delimiter.
NewFileList .= RegExReplace(FileList,"[0-9]{14},","")
GuiControl,, MyListBox, %NewFileList%
Gui, Show, w550 h140, hello
return
MyListBox:
if (A_GuiEvent != "DoubleClick")
return
ButtonOK:
GuiControlGet, MyListBox
GuiClose:
GuiEscape:
ExitApp
我无法在列表中进行反向排序。我不明白如何按名称、最后修改时间或任何属性正确地对我的文件进行排序。
Gui, Add, Text, title?, Pick a file to launch from the list below.`nTo cancel, press ESCAPE or close this window.
Gui, Add, ListBox, vMyListBox gMyListBox w500 r5
Gui, Add, Button, Default, OK
Loop files, C:\Users\me\Downloads\*.png
{
FileList = %A_LoopFileName%
Sort, FileList, R ; Sort, reverse order.
GuiControl,, MyListBox, %FileList%
}
Gui, Show, w550 h140, hello
return
MyListBox:
if (A_GuiEvent != "DoubleClick")
return
ButtonOK:
GuiControlGet, MyListBox
GuiClose:
GuiEscape:
ExitApp
看起来我基本上是在循环中循环。或者我无法完全描述的错误。但是最好先画出列表,然后对其进行排序,然后像这样应用于 gui...
Gui, Add, Text, title?, Pick a file to launch from the list below.`nTo cancel, press ESCAPE or close this window.
Gui, Add, ListBox, vMyListBox gMyListBox w500 r5
Gui, Add, Button, Default, OK
FileList :=
Loop files, C:\Users\me\Downloads\*.png
{
FileList .= A_LoopFileName . "|"
}
Sort, FileList, R D| ; Sort, reverse order. Use '|' as the Delimiter.
GuiControl,, MyListBox, %FileList%
Gui, Show, w550 h140, hello
return
MyListBox:
if (A_GuiEvent != "DoubleClick")
return
ButtonOK:
GuiControlGet, MyListBox
GuiClose:
GuiEscape:
ExitApp
如果需要对上次修改或创建进行排序。您可以将其添加到列表中,同时在循环中构建它,然后在排序发生后使用 14 位数字上的正则表达式替换将其删除。
Gui, Add, Text, title?, Pick a file to launch from the list below.`nTo cancel, press ESCAPE or close this window.
Gui, Add, ListBox, vMyListBox gMyListBox w500 r5
Gui, Add, Button, Default, OK
FileList :=
Loop files, C:\Users\me\Downloads\*.png
{
FileList .= A_LoopFileTimeModified "," A_LoopFileName "|"
}
Sort, FileList, R D| ; Sort, reverse order. Use '|' as the Delimiter.
NewFileList .= RegExReplace(FileList,"[0-9]{14},","")
GuiControl,, MyListBox, %NewFileList%
Gui, Show, w550 h140, hello
return
MyListBox:
if (A_GuiEvent != "DoubleClick")
return
ButtonOK:
GuiControlGet, MyListBox
GuiClose:
GuiEscape:
ExitApp