How do you make a DropDownList of Subfolders

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
mrmech
Posts: 81
Joined: 07 Dec 2015, 17:37

How do you make a DropDownList of Subfolders

19 Nov 2022, 16:23

I want to make a DropDownlist from a list of folders named after music artists.
Each Artist Subfolder is in a genre folder.

Examples:

Code: Select all

W:\Music\Artists\African\Antibalas
W:\Music\Artists\African\Fela Kuti
W:\Music\Artists\Country\Gillian Welch
W:\Music\Artists\Electronic\4 Hero
W:\Music\Artists\Electronic\A Band Called Flash
W:\Music\Artists\Hip-Hop\2Pac
W:\Music\Artists\Hip-Hop\A Tribe Called Quest
W:\Music\Artists\Jazz\Adrian Younge
W:\Music\Artists\Jazz\Alice Coltrane
W:\Music\Artists\Latin\Afro Cuban All Stars
W:\Music\Artists\Latin\Banda Black Rio
W:\Music\Artists\Rock\Artesia
W:\Music\Artists\Rock\Beck
W:\Music\Artists\Soul\Adrian Younge
W:\Music\Artists\Soul\Al Kent
W:\Music\Artists\Soundtrack\Seu Jorge
I only want the Artist Names in the list and I want to ignore everything else in the file path.

The script I wrote is only returning 1 Artist Name per Genre folder:

Code: Select all

^+!r::

Gui, Add, Text,	, Artist Names
Gui, Add, DropDownList,	gChoice	vArtistName
Loop, Files, % "W:\Music\Artists\*", D
{
	ParentFolder := A_LoopFileFullPath
	Loop, Files, % ParentFolder "\*", D
	ParentFolder := A_LoopFileName
	;-Msgbox % ParentFolder
	GuiControl,, ArtistName, %ParentFolder% 
}

Gui, Show, AutoSize, New GUI Window
Return

Choice:
gui, submit, nohide

GuiClose:
Reload
return
User avatar
AlphaBravo
Posts: 586
Joined: 29 Sep 2013, 22:59

Re: How do you make a DropDownList of Subfolders

19 Nov 2022, 17:25

give this a try

Code: Select all

folderList := ArtistList := "", oArtist := []
loop, files, % "W:\Music\Artists\*", DR
	folderList .= A_LoopFilePath "`n"

for i, line in StrSplit(folderList, "`n")
	if !InStr(folderList, line "\")
		oArtist[RegExReplace(line, "^.*\\")] := 1

for Artist in oArtist
	ArtistList .= (ArtistList?"|":"") Artist

ArtistList := StrReplace(ArtistList, "|", "||",, 1)
Gui, Add, Text,	, Artist Names
Gui, Add, DropDownList,	gChoice	vArtistName, % ArtistList
Gui, show
return

Choice:
Gui, Submit, NoHide
ToolTip % ArtistName
return
mrmech
Posts: 81
Joined: 07 Dec 2015, 17:37

Re: How do you make a DropDownList of Subfolders

19 Nov 2022, 18:01

Thanks for the response, but the script didn't work. It basically gave me a list of all the Album folders which would be the lowest folders in the tree. Maybe I should have mentioned that the Artist Name folders have subfolders and files in them.

For example:
W:\Music\Artists\African\Peter King\Albums\Peter King - Shango\Peter King - Shango - 01 - Shango.mp3

I emboldened the folder I'm trying to capture (Peter King).
User avatar
flyingDman
Posts: 2840
Joined: 29 Sep 2013, 19:01

Re: How do you make a DropDownList of Subfolders

19 Nov 2022, 19:51

So it is the 4th layer that you try to capture? Which you could get using:

Code: Select all

path := "W:\Music\Artists\African\Peter King\Albums\Peter King - Shango\Peter King - Shango - 01 - Shango.mp3"
msgbox % strsplit(path,"\").5
try:

Code: Select all

loop, files, %path%\*.*, RD
	lst .= strsplit(A_LoopFileFullPath,"\").5 "|"
sort, lst, UD|
Gui, Add, DropDownList, vchoice, % lst
gui, show
(not tested)
14.3 & 1.3.7
mrmech
Posts: 81
Joined: 07 Dec 2015, 17:37

Re: How do you make a DropDownList of Subfolders

20 Nov 2022, 12:49

Nailed it! Thanks, flyingDman!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 166 guests