[Closed] doesFileExist "considerable slowdown…"
Hi All,
I’m using “doesFileExist thepath” to check that all the bitmaps exist in a scene are valid and available, but I get alot of slowdown (taking into account that it has to access the file servers) when I have more than about 10 bitmaps in a scene.
Is “doesFileExist thepath” the most efficient MAXScript command to use for this situation?
Can anyone suggest something better?
Thanks,
Mike
This is one…
((getFiles <filespec>).count > 0)
…not sure if that’d be faster, exactly.
Or you could go through ATSOps – that has a method to automatically get you the list of any missing files.
meditmaterials[1].diffusemap = bitmaptexture filename:"c:\
onexist.png"
Bitmaptexture:Bitmap
ATSOps.GetFilesByFileSystemStatus #missing &foo
1
foo
#("c:
onexist.png")
Finally, there’s .NET – but try the above first…
I took the opportunity and tried the doesFileExist agains it’s dotnet equivalent and the result surprised me hehe… Here’s the script:
(
Dir=dotnetclass "System.IO.Directory"
TheFiles=Dir.GetFiles @"\\manager\3D STUFF\IAM\TEXTURES\3DSMAX ARCHMAT"
Fi=dotnetclass "System.IO.File"
print "doesFileExist"
local start=timestamp()
for i in TheFiles do doesFileExist i
local end=timestamp()
format "Processing took % seconds
" ((end - start) / 1000.0)
print "System.IO.File.Exists"
local start=timestamp()
for i in TheFiles do Fi.Exists i
local end=timestamp()
format "Processing took % seconds
" ((end - start) / 1000.0)
)
And the result:
"doesFileExist"
Processing took 0.188 seconds
"System.IO.File.Exists"
Processing took 0.234 seconds
OK
This directory has 438 files… dunno how it will behave with more files, I guess you could try it! Cheers