Batch clean .max files script does not open files in subfolders

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone! Probably a very simple question, but one I can not figure out.
So, long story short, I have about a 1000+ .max files polluted with random Fire and Atmospheric effects, and littered with empty animation layers. This has turned out to be a bit of a performance hog, so I am trying to clean the files. Naturally, manually cleaning them will not do. So I tried writing this script, which seems to be working fine (even though it is truly painfully slow for some reason, but let's say I can live with that. If anyone can help with this too however, all the better).
My real problem is this however - The script only processes the .max files in the folder I select, but not in any subsequent subfolders. I have been banging my head on how to get this to work, and I have had no luck as of yet. Any help in this regard would be truly and greatly appreciated, since my library structure is is divided into many, many subfolders.
And here is the current script:
thePath = getSavePath()--get a path dialog to specify the path
if thePath != undefined do--if the user did not cancel
(
theFiles = getFiles (thePath+"\\*.max") --collect all max files in the dir.
for f in theFiles do-- go through all of them
(
loadMaxFile f missingExtFilesList:&val missingExtFilesAction:#logmsg quiet:true--load the next file
-----------------------------------------------------------
-- MAKE SOME SCRIPTED CHANGES TO THE SCENE HERE...
while numAtmospherics > 0 do deleteAtmospheric 1
while numEffects > 0 do deleteEffect 1
--while AnimLayerManager.getLayerCount() > 0 do AnimLayerManager.deleteLayer 1
c=AnimLayerManager.getLayerCount()
for i = 2 to c do AnimLayerManager.deleteLayer 2
IsolateSelection.ExitIsolateSelectionMode()
-----------------------------------------------------------
saveMaxFile f --save the file back to disk
)--end f loop
-- resetMaxFile #noPrompt --at the end, you can reset
)--end if