Little array problem

theFiles=getFiles ("H:\\Try"+"\\"+"*")
 
theImgType=#(".bmp", ".jpg",".jpe",".jpeg",".cin",".gif",".hdr",".pic",".exr",".fxr",".png",".psd",".rgb",".sgi",".rla",".rpf",".tga",".vda",".icb",".vst",".tif",".yuv",".dds")
myProxyType=#(".vrmesh", ".mib",".fpx")
myVideoType=#(".avi", ".mpg",".mpeg",".mov")
 
fn generateUnknowFile theArr=
	(
		myFile=#()
 
		fileTypeArr=theImgType+myProxyType+myVideoType
		theIcon=AddIconPath+"\\"+"Unknown.png"
 
		for i in theArr do 
		(
			for u in fileTypeArr do
			(
			theFile=i	
			myType=toLower (getFilenameType (filenameFromPath theFile))
			otherType=u
 
			if myType!=otherType do append myFile theFile
			)
		)
		 myFile
		--print myFile
	)
generateUnknowFile theFiles

The problem is, How to get other extension other than in theImgType,myProxyType,myVideoType like ["H:\\Try\apple.dll"].
I try using my function above, but seem it fail, it constantly generate the file that contain extension in the theImgType,myProxyType,&myVideoType

Thank you very much

Comments

Comment viewing options

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

ok got it.thanks a bunch

ok got it.i'll use match pattern.

thanks a bunch miauu.

miauu's picture

Your method fails because of

Your method fails because of the nested for loop. Let say that your first extension is dll. You compared it with all extensions(in the fileTypeArr ) and the script add it to the myFile array. The second extension is png. When you compare PNG with the fileTypeArr , when the script compare the png and bmp the result of myType!=otherType is true(png is different than bmp) and the script add the png to myFile array.

The code below works. If it add some files more than once use while statement in the for i in theArr.

for i in theArr do 
			(
				myType = toLower (getFilenameType (filenameFromPath i))
				if (findItem fileTypeArr myType) == 0 do append myFile i
			)
			myFile

Edit: Maxscript help file says that matchPattern is much faster than findItem, so you can try to use matchPattern.

Comment viewing options

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