View Full Version : Search subfodlers for a file
04-20-2009, 03:22 PM
Im writing a script to sawp a 2D VIZBlock for a 3d max file via proxy.
It does this by finding the .max file with the same name as the vizblock.
However we have .max files in several different subfolders.
Any idea how I can search a folder and it's subfolders for a filename match?
04-20-2009, 04:57 PM
Check the "External File Methods" section in the help file. There is a sample of a recursive file finding function that should give you an idea of how to find a file.
04-20-2009, 05:00 PM
Thanks dude, just found it :)
04-20-2009, 05:19 PM
Or you can try this:
theFile=(sFiles.GetFiles @"C:\2DProxy" "my2dproxy.max" searchSubDirs.AllDirectories)
if theFile==undefined then print "File not found."
Great example thanks!!! Do you know if it's possible to find and sort filesequences with dotnet exclusivly. I have a maxscript routine, but on large directories it get's slow. Is there a build in way for sorting files and or return file sequences?
Thanks for all these dotnet variants of script, really helpfull!!
04-21-2009, 09:14 AM
Yeah that works great!
just a refinement to the if statement it needs to be a double =
if theFile == undefined then print "File not found."
04-21-2009, 10:11 AM
Hi Johan and thanks!
If you know the prefix of the file sequence then is quite easy, you just have to do something like this:
theFiles=sFiles.GetFiles @"C:\RenderSeq" "render_*.tga"
I guess that should work :D
Yes, that assumes I know what files I want, I'm looking for a dotnet way of getting the files as an array of arrays, sorting the files by sequence. I have this in maxscript, 30+ lines of code or something and it works ok, but it can get slow on large sequences because of all the checking and sorting. So I thought maybe dotnet has a way to automagicly give me a sorted array of arrays including all sequences, just like combustion or fusion can do in the file browser. But I think even dotnet needs some help with that ;)
04-21-2009, 11:04 AM
I believe it does! I had looked into this as i've been working on a DotNet RAM Player but i didnt find an acceptable solution with regard to file sequences. I wanted an AFX style listing of individual files and sequences, but I ended by using an identical method to Artur's published method. VBdotnet gives you a .toarray base function method that allows you to perform a basic name sort in the way Artur's MXS sort method does. Anything more complex you might have to implement an IComparer interface.
In the end I went with a couple of options, firstly a threaded treeview browser that performed the recursive search which was good, but could take some time on deeply nested folder structures, and finaly with an inherited directory treeview that used a temporary node structure on each folder and performed the search quickly when the node was expanded. That way, the seach logic was built into the control and you don't need to search through a whole drive all at once. It was fast and no longer needed the background thread.
I'll look into this!
But I'm definitely not going for a treeview but for a flatview and since I use a struct I store the results of my search there, since it's not a constant update thing. I just want a flat overview of a folder and it's subfolders.http://public.subd.nl/cgtalk/2009-04-21_1318.png
And it's pretty fast on small sequences, but slower on big ones, so I'd like to do some testing. Thanks for all the info!
04-21-2009, 12:27 PM
cool! let me know if you find anything useful. At the moment, Each folder is a sequence render so its not a problem with the tree, as I know each node is a folder if images. here's my current UI -
I like your UI better ;) Is that a custom RAM player?!
04-21-2009, 12:47 PM
heh!, a poor man's combustion!. :)
yes, it's a custom RAM player. I got fed up loading and changing aspect ratios in RAM player ever time. It stores Project paths so you can load different render folders from the menu. I'm using a custom image library and currently finding it about twice as fast as RAM player too, not just because of the faster processing, but as it's threaded so I can start playback while it is caching the rest.
I'm ironing out a few bugs at the moment and hoping to release it to the community soon.
*picks jaw from floor...
That's really cool! I really hope autodesk people are reading stuff like this, cause that's how it should be, a good 3D framework and a very extensible UI. Amazing stuff Pete, that Swami Lama's lovechild stuff it's true! ;)
Thanks for sharing!
04-22-2009, 10:32 AM
ha ha, I wish! he wasn't around as much as I liked, but he was a great father. :love:
04-22-2009, 10:32 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.