Page 1 of 1

script for treeview of a folder structure?

Posted: 22 Oct 2020, 16:15
by BGM
Is there a script already made for a treeview to load a folder structure? I don't want to re-invent a wheel.

I want to choose a folder and have it and it's subfolders appear as items in the tree. I can probably figure out how to do this, but was hoping to save some time with kindly-already-existing code.

Re: script for treeview of a folder structure?

Posted: 22 Oct 2020, 18:10
by kczx3
Don’t the docs have an example that does this?

Re: script for treeview of a folder structure?

Posted: 23 Oct 2020, 08:38
by BGM
The docs have an example of how to make tree items and sub-tree items.

Anyway, I spent the time.

Code: Select all

		loop, files, %rootfolder%\*, D
		{
			parentfolder := a_loopfilename

			parentitem := tv_add(a_loopfilename)
			loop, files, %a_loopfilefullpath%\*, D
			{
				tv_add(a_loopfilename,parentitem)
			}
		}

Re: script for treeview of a folder structure?

Posted: 23 Oct 2020, 08:44
by kczx3
The documentation example I mentioned is here - https://www.autohotkey.com/docs/commands/TreeView.htm#ExAdvanced

I feel like that's pretty self-explanatory. Just modify it to prompt for the folder instead of hard coding the root...