Loop, Files with If statements. Need help with file pattern. Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
KilliK
Posts: 229
Joined: 10 Mar 2016, 21:19

Loop, Files with If statements. Need help with file pattern.

10 Apr 2019, 20:07

Hello.
I have created a script with the Loop,Files command which scans a folder for all its files and depending on the ext/name of each file, it processes it accordingly.
I am doing only one Loop and use an if statement for each situation. Most of the if statements have this syntax:

Code: Select all

if (A_LoopFileExt in %File_Types%)
which works fine.

But I dont know how to write the if statement for the files with filename which conform to either of the two pattern criteria:

SelectedText*.txt
the * here is a random number

panel-*-image-*
the first * is a random number, the second * is random letters,numbers and characters. it also deosnt have an extension.

I know I can use two loops with their own file patterns and look specifically for those files, but I want to avoid that since I am already doing one Loop for all files.

How do I code this, do I use contains, InStr, regex, etc?
Osprey
Posts: 453
Joined: 18 Nov 2017, 05:50

Re: Loop, Files with If statements. Need help with file pattern.  Topic is solved

10 Apr 2019, 20:23

Try doing If(RegExMatch(A_LoopFileName, "SelectedText.*.txt")) and If(RegExMatch(A_LoopFileName, "panel-.*-image-.*")). .* in a RegEx pattern is a wildcard.
KilliK
Posts: 229
Joined: 10 Mar 2016, 21:19

Re: Loop, Files with If statements. Need help with file pattern.

10 Apr 2019, 21:19

that did it, thank you very much for your help.

Return to “Ask For Help”

Who is online

Users browsing this forum: Google [Bot], Hash817, notnaochief, WeedTrek and 32 guests