With a file loop, any way to match multiple extensions?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ManaUser
Posts: 4
Joined: 25 Nov 2018, 23:53

With a file loop, any way to match multiple extensions?

Post by ManaUser » 20 Dec 2018, 17:11

Hi, old AHK user but I'm kinda rusty and I don't remember if there's a way to do this. Using Loop FilePatern (or Loop Files, FilePatern), is there any way to match multiple file extensions? Like jpg and png for instance. I guess in this particular example I could use ??g, but that's kinda hackish and only works by happy accident. I know there are a couple other options like grabbing all the files and checking their names with my own logic or using separate loops for each extension, but I just wanted to ask if there's a simple way first.

iseahound
Posts: 1472
Joined: 13 Aug 2016, 21:04
Contact:

Re: With a file loop, any way to match multiple extensions?

Post by iseahound » 20 Dec 2018, 17:55

Just do

Code: Select all

Loop, Files, some folder path
{
if (A_LoopFileExt ~= "TXT|EXE|DOC|PNG")
MsgBox % "Match Found: " A_LoopFileLongPath
}

ManaUser
Posts: 4
Joined: 25 Nov 2018, 23:53

Re: With a file loop, any way to match multiple extensions?

Post by ManaUser » 20 Dec 2018, 18:53

Well that would be an example of "grabbing all the files and checking their names with my own logic", wouldn't it? But I suspected that's what I'd have to do, so thanks for the confirmation.

It's just that I'm dealing with a ridiculous number of files, potentially like half a million, so I want to make this as streamlined as possible. But if that's the best way, that's the best way.

Post Reply

Return to “Ask for Help (v1)”