Page 1 of 1

help with geting list from loop

Posted: 22 Apr 2018, 05:19
by Tomer
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")

Re: help with geting list from loop

Posted: 22 Apr 2018, 06:48
by swagfag

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")
}

Re: help with geting list from loop

Posted: 22 Apr 2018, 07:25
by Tomer
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)
}


Re: help with geting list from loop  Topic is solved

Posted: 22 Apr 2018, 08:18
by swagfag
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 . "\"), "")

Re: help with geting list from loop

Posted: 23 Apr 2018, 03:27
by Tomer
tnx swagfag
works great (I am not an advocate of functions either)