Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Wildcard Folders


  • Please log in to reply
20 replies to this topic
LBJ
  • Members
  • 24 posts
  • Last active: Apr 04 2011 06:18 AM
  • Joined: 03 May 2007

if (i:=RegExMatch(Pattern,"(?<=[*?])\"))

That would allow wildcards only at the end of the name. Notice the pattern I used in my test: ?u*y.


You're absolutely correct of course. :-)

Morpheus
  • Members
  • 475 posts
  • Last active: Oct 21 2014 11:08 AM
  • Joined: 31 Jul 2008

What I didn't say is it's only of benefit if you specifically have a use for it. I don't. Thinking about it, though, I can understand how much better it would be for someone that has a need for it.

I think I mainly posted because xx3nvyxx's solution seemed overcomplicated, as does yours. Here is my crack at it:

Glob(list, "C:\Program Files\?u*y\*\*.exe")
MsgBox %list%

Glob(ByRef list, Pattern, IncludeDirs=0)
{
    if (i:=RegExMatch(Pattern,"[*?]")) && (i:=InStr(Pattern,"",1,i+1))
        Loop, % SubStr(Pattern, 1, i-1), 2
            Glob(list, A_LoopFileLongPath . SubStr(Pattern,i), IncludeDirs)
    else
        Loop, %Pattern%, %IncludeDirs%
            list .= (list="" ? "" : "`n") . A_LoopFileLongPath
}
It seems too simple... maybe I missed something? :lol:



Thanks Lexikos, I needed this today. :-)

Sccrluk9
  • Guests
  • Last active:
  • Joined: --
I know this is super old but this is exactly what I needed today. Thanks a ton for the help

lsavell
  • Members
  • 37 posts
  • Last active: Feb 13 2012 10:13 PM
  • Joined: 22 May 2010
I was hoping to use this in a simple cleanup script, but I receive an error message when trying to run this.

"Warning: using value of uninitialized variable

specifically list (a local variable with the same name as global)"

Pops up a couple of times, and then the script works. Anything I do to turn off the error message or correct the issue? Not exactly sure what it's barking at me for.

  • Guests
  • Last active:
  • Joined: --
Remove #Warn from your script

kilogrammer
  • Members
  • 2 posts
  • Last active: Sep 07 2014 05:06 AM
  • Joined: 21 Aug 2014

Although, I didn't quite grasp how this works. This is exaclty what I needed, and I was able to modify it to meet my requirements. 

I know its been a good 8 years, but thanks guys, especially Lexikos.