--UNC Name  exChange 0.1 alpha
--date:9/23/2005
--Written By Zhang Yang
--notes: change the NewUNCName and OldUNCName part first.


--Init Var
--Change this server name
NewUNCName="//BEIL3VAX06/"
OldUNCName="//newserver1111/"

changedMapCount=0

debug=createFile "c:/temp/debug.log"


fn cnPath pathStr= (
	for i=1 to pathStr.count do if pathStr[i]=="\\" do pathStr[i]="/"
	pathStr
	)


--main function
fn changeMaps item = (		
	if classof(item)==SubAnim and (classof item.value)==Bitmaptexture then
		(	
		local fileStr=cnPath item.filename
		if (findString fileStr OldUNCName)!=undefined do 
			(
			format "change this:% on this:%\n"  fileStr item.value to:debug		
			changedMapCount+=1
			item.filename=replace fileStr 1 (oldUNCName.count) NewUNCName
			)
		)
	else if item!=undefined do
		(
		--get all the properties in the material or texturemap
		local subNum=item.numsubs
		format "\ntotal % subAnim Track\n" SubNum to:debug
		if subNum>=1 do for i=1 to subNum do ChangeMaps item[i] 
		)
	endif
	)
	
for proMat in sceneMaterials do
	(
		changeMaps proMat
		
	)
format "Finish!Total:% missing bitmaps have been deleted." changedMapCount to:debug
flush debug


