Notifications
Clear all

[Closed] development toops: listing all the directories and subdirectories

Hi,

I’m writing some development tools for myself to better develop my scripts and pipeline. I want to have all the scritps to be available from one place, no matter the location. So I wrote two functions to do this:

		fn getDirs dir = (
			getDirectories (dir + @"\*")
		)
		
		fn getScripts dir = (
			global devDirs = #()
			local dirs = getDirs dir
			for i=1 to dirs.count do (			
				getScripts dirs[i]
				append devDirs dirs[i]
				print dirs[i]
			)
			print devDirs
		)

When I run my function to get all the directories for my main path: getScripts @“my_path” the listener properly lists all the directories. But the array divDirs is completely different. Why does it print out properly but does not append them?

for obviuos reasons dont try to test this on “C:”

3 Replies

search the mxs help for ‘getFilesRecursive’

Thanks.

I can’t figure out what is the difference between my version and mxsc help version:

fn getFilesRecursive root pattern = (
	dir_array = GetDirectories (root+"/*")
	for d in dir_array do
		join dir_array (GetDirectories (d+"/*"))
	my_files = #()
	for f in dir_array do
		join my_files (getFiles (f + pattern))
	my_files
)

They both do exactly the same and the structure seems to be similar.

Well… I’ll just use the mxs help version. Maybe I’ll get the idea later

mxs help function is not really recursive. i does search in sub-directories but the function don’t use recursion. which makes it faster and memory friendly