help with geting list from loop Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

help with geting list from loop

22 Apr 2018, 05:19

hello,

i'd like to get a list only of the exclude folders aswell,
so the list in the msgbox will be displayed exactly like:

"Windows" "Users" "Program Files" "ProgramData" "$Recycle.Bin"

Code: Select all

vDir1 := "C:"
vList := ""
Loop, Files, % vDir1 "\*", D ; folders
{
	if !(A_LoopFileName = "Windows")
	&& !InStr(A_LoopFileName, "Users") && !InStr(A_LoopFileName, "Program Files") && !InStr(A_LoopFileName, "ProgramData") && !InStr(A_LoopFileName, "$Recycle.Bin")
		vList .= A_LoopFileFullPath "|"
}

vList := SubStr(vList, 1, -1)
MsgBox, % StrReplace(vList, "|", "`n")
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: help with geting list from loop

22 Apr 2018, 06:48

Code: Select all

vDir1 := "C:"
vList := ""
folderBlacklist := "Windows,Users,Program Files,ProgramData,$Recycle.Bin"
excludedFolders := ""

Loop, Files, % vDir1 "\*", D ; folders
{
	if A_LoopFileName in %folderBlacklist%
	{
		excludedFolders .= append(A_LoopFileFullPath)
		continue
	}
	
	vList .= append(A_LoopFileFullPath)
}

print(vList)
print(excludedFolders)
return

append(str) {
	return str . "|"
}

print(str) {
	str := SubStr(str, 1, -1)
	MsgBox, % StrReplace(str, "|", "`n")
}
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: help with geting list from loop

22 Apr 2018, 07:25

thanks!

1. this is total new code, any chance to stick the original code ?

2. anyway, i updated the code to get the "folderBlacklist" in this way:
"Windows" "Users" "Program Files" "ProgramData" "$Recycle.Bin"

problem is this change effects now on the "excludedFolders" list aswell..

Code: Select all

vDir1 := "C:"
vList := ""
folderBlacklist := "Windows,Users,Program Files,ProgramData,$Recycle.Bin"
excludedFolders := ""

Loop, Files, % vDir1 "\*", D ; folders
{
	if A_LoopFileName in %folderBlacklist%
	{
		excludedFolders .= append(A_LoopFileFullPath)
		continue
	}
	
	vList .= append(A_LoopFileFullPath)
}

print(vList)
print(excludedFolders)
return

append(str) {
	return str . ""
}

print(str) {
	str := SubStr(str, 1, -1)
	MsgBox, % StrReplace(str, "c:\", a_space)
}

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: help with geting list from loop  Topic is solved

22 Apr 2018, 08:18

without functions

Code: Select all

vDir1 := "C:"
vList := ""
folderBlacklist := "Windows,Users,Program Files,ProgramData,$Recycle.Bin"
excludedFolders := ""

Loop, Files, % vDir1 "\*", D ; folders
{
	if A_LoopFileName in %folderBlacklist%
	{
		excludedFolders .= """" . A_LoopFileFullPath . """ "
		continue
	}
	
	vList .= A_LoopFileFullPath . "|"
}

vList := SubStr(vList, 1, -1)
MsgBox, % StrReplace(vList, "|", "`n")
MsgBox, % StrReplace(excludedFolders, (vDir1 . "\"), "")
User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: help with geting list from loop

23 Apr 2018, 03:27

tnx swagfag
works great (I am not an advocate of functions either)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], jameswrightesq and 295 guests