Find Filename Using Wildcard and Variable

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
john68
Posts: 11
Joined: 09 Nov 2015, 15:38

Find Filename Using Wildcard and Variable

07 Dec 2019, 18:15

I'm trying to use a combination of a wildcard and a variable to select a file (the first matching file found). As a simplified example:

Code: Select all

var := 1
		
		Loop, E:\xxjb\A\%InFolder%\*%var%.txt
		{
		
			SelectedFile := A_LoopFileName
	break
		}
	msgbox, %SelectedFile%
	}
In the "Loop" line, if I replace %var% with the actual value (1), it works fine.
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Find Filename Using Wildcard and Variable

07 Dec 2019, 19:09

What you showed works (once you remove the extraneous } and define a value for InFolder that makes it a valid file path. You probably have some other error in your non-simplified version. If you can show the code from the non-simplified version, then it may be possible to spot the problem. Using a wildcard and a variable is not the problem.
john68
Posts: 11
Joined: 09 Nov 2015, 15:38

Re: Find Filename Using Wildcard and Variable

08 Dec 2019, 00:20

Thank you, I did have an invalid file path due to a math calculation in the wrong place. Was easy to locate once you mentioned the potential problem.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 107 guests