loop files Recurse limit levels Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
xinxilas
Posts: 27
Joined: 18 Nov 2015, 16:54

loop files Recurse limit levels

14 Jan 2019, 00:51

Hello friends, using loop file, is there any way to limit how deep it will get into sub-directories ?

example

c:/1/a
c:/1/b
c:/1/c/no

c:/2/a
c:/2/b
c:/2/c/no

What if want to get in only until second level of the folders(a, b, c), avoiding folder "no" for example?

Any tip?

thanks!
User avatar
TheDewd
Posts: 1166
Joined: 19 Dec 2013, 11:16
Location: USA

Re: loop files Recurse limit levels  Topic is solved

14 Jan 2019, 08:39

Code: Select all

#SingleInstance, Force

Loop, Files, *.*, FR
{
	StrReplace(A_LoopFileFullPath, "\", "\", DirCount) 

	If (DirCount = 3) {
		Continue 
	}

	MsgBox, % A_LoopFileLongPath
}

Assuming that your files and directories are setup similar to the list below:

Code: Select all

<DIR>	1\
<FILE>	1\1.txt
<DIR>	1\a\
<FILE>	1\a\a.txt
<DIR>	1\b\
<FILE>	1\b\b.txt
<DIR>	1\c\
<FILE>	1\c\c.txt
<DIR>	1\c\no\
<FILE>	1\c\no\no.txt
<DIR>	2\
<FILE>	2\2.txt
<DIR>	2\a\
<FILE>	2\a\a.txt
<DIR>	2\b\
<FILE>	2\b\b.txt
<DIR>	2\c\
<FILE>	2\c\c.txt
<DIR>	2\c\no\
<FILE>	2\c\no\no.txt
<FILE>	Script_With_File_Loop.ahk
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
xinxilas
Posts: 27
Joined: 18 Nov 2015, 16:54

Re: loop files Recurse limit levels

14 Jan 2019, 15:15

This is the best community ever, thank you,

Return to “Ask For Help”

Who is online

Users browsing this forum: afe, AHKStudent, Google [Bot], jony26, Rohwedder, SOTE and 52 guests