searching through folders

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

searching through folders

24 Oct 2018, 10:53

Lets say I have 5 folders (these 5 folders are in the Ah2 folder below)
Lets say each of the 5 folders has 5 subfolders
Lets say I am look for a file, I have to loop through the 5 main folders and each of their 5 subfolders.

Here is what I have that is not working. Thanks for any help.

Code: Select all

theFile = monthly report
Loop, \\10.10.xx.x\AudioNAS\AH2\*,1    
msgbox %A_LoopFileFullPath%
{

	Loop, %A_LoopFileFullPath%\* ,1   
	{
	msgbox %A_LoopFileFullPath%    

		Loop, %A_LoopFileFullPath%\* theFile,1    
		{
		msgbox %A_LoopFilePath%    
		}
	}
}
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: searching through folders

24 Oct 2018, 11:03

Does the "monthly report" file not have a proper file extension?

Code: Select all

theFile := "monthly report"

Loop, Files, \\10.10.xx.x\AudioNAS\AH2\*.*, FR
{
	If (A_LoopFileName = theFile) {
		MsgBox, % A_LoopFileLongPath
	}
}
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: searching through folders

24 Oct 2018, 11:26

this loops the main folder and their sub folders but cant find the file in one of the sub folders

Code: Select all

Loop, C:\Users\Audio1\Desktop\Ah2\*,2,1
{
msgbox %A_LoopFileName%  123123
}
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: searching through folders

24 Oct 2018, 12:41

figured it out. I'm just given the name or part of the file name. This code searches 50+ folders and who knows how many files and opens the folder that contains the file in max 3 seconds.

Code: Select all

Loop files, \\x.x.x.x\AudioNAS\AH2\* %theFile% *,R

{
StringSplit, word, A_LoopFilePath , \
theFolder = \%word2%\%word3%\%word4%\%word5%\%word6%\%word7%
run, %theFolder%
sleep 1000
send AH2 %UserInput%       ;this will select the file so your eyes are drawn to the highlighted file
return
}
sbrady19
Posts: 337
Joined: 12 Apr 2018, 05:22
Location: Central Florida
Contact:

Re: searching through folders

25 Oct 2018, 06:43

dewd, what is FR?

Loop, Files, \\10.10.xx.x\AudioNAS\AH2\*.*, FR
User avatar
TheDewd
Posts: 1510
Joined: 19 Dec 2013, 11:16
Location: USA

Re: searching through folders

25 Oct 2018, 07:17

sbrady19 wrote:
25 Oct 2018, 06:43
dewd, what is FR?

Loop, Files, \\10.10.xx.x\AudioNAS\AH2\*.*, FR

Loop, Files, FilePattern [, Mode] ; v1.1.21+
Documentation wrote:Mode [v1.1.21+]
Zero or more of the following letters:

D: Include directories (folders).
F: Include files. If both F and D are omitted, files are included but not folders.
R: Recurse into subdirectories (subfolders). If R is omitted, files and folders in subfolders are not included.
F tells the loop to match on filenames. R tells it to recurse into subdirectories. If you use D it will also match any folder names that match your filename.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 235 guests