AutoHotKey 如何知道检索到的路径是文件还是文件夹?

AutoHotKey how to know the retrieved path is for a file or folder?

我正在使用循环、文件模式来检索一组文件和文件夹 我想知道如何让 AHK 向我发送消息,如果它是文件夹,如果它是文件夹就跳过它?

希望这三种方式能帮助你理解:

recurse = 1
loop, *.*, 2, %recurse%
    msgbox, %a_index%: FOLDER %a_loopFileName%
loop, *.*, 0, %recurse%
    msgbox, %a_index%: FILE %a_loopFileName%
loop, *.*, 1, %recurse%
{
    ifinstring, a_loopFileAttrib, D
        msgbox, %a_index%: FOLDER %a_loopFileName%
    else
        msgbox, %a_index%: FILE %a_loopFileName%
}

FileGetAttrib

Reports whether a file or folder is read-only, hidden, etc.

但是,您可以使用它来确定某物是文件夹还是文件。

例子

MyPath := "C:\Windows"
FileGetAttrib, MyAttributes, %MyPath%
If InStr(MyAttributes,"D")
    MsgBox I am a folder.
Else
    MsgBox I am a file.

来源:http://ahkscript.org/docs/commands/FileGetAttrib.htm