Recursive not inclduing files in root directory?

Hi,

I have lifted this portion of script from the maxscript reference to loop through all .max files in a root folder and all child folders. The script processes .max files in child folders but not .max files in the root folder... could someone help me figure it out please?

--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
 	)
 
	location = getSavePath caption:"Files to process..."
 --get all .max files from the specified folder  --and all its subfolders:
getFilesRecursive location "*.max"  -- change the folder here
 
<code>

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

Try this:

(
	fn getFilesRecursive root pattern =
 	( 
		dir_array = GetDirectories (root+"/*")
 
		for d in dir_array do
		(
			join dir_array (GetDirectories (d+"/*"))
		)
 
		join dir_array (GetDirectories root)
 
		my_files = #()
		for f in dir_array do
		join my_files (getFiles (f + pattern))
		my_files
 	)
 
	location = getSavePath caption:"Files to process..."
	--get all .max files from the specified folder  --and all its subfolders:
	getFilesRecursive location "*.max"  -- change the folder here
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.