Notifications
Clear all

[Closed] Replace all materal extensino from tga to dds?

Ok looking for a script that will basically go though all materials, and replace the extension from .tga, to .dds Paths are all the same.

Anyone point me in the direction of something like that?

5 Replies

I wrote this some time ago, it sets all the extensions for images to one type.

(
  fileFormatType = "dds"
  for i = 1 to sceneMaterials.count do
  	(
  	try(
  		trimmedFile = #()
  		bitmapname = sceneMaterials[i].diffuseMap.filename
  		trimmedFile = filterstring bitmapname " \ "
  		baseFile = trimmedFile[trimmedFile.count]
  		bitmapFileName = #()
  		bitmapFileName = filterstring baseFile "."
  		myVal = bitmapFileName.count - 1
  		newfilename = ""
  		for x = 1 to myVal do
  		(
  			newfilename = append newfilename bitmapFileName[x]
  			newfilename = append newfilename "."
  		)
  		finalBitmapName = newfilename + fileFormatType 
  		sceneMaterials[i].diffuseMap.filename = finalBitmapName
  	)catch(
  	for j = 1 to sceneMaterials[i].numsubs do
  		(
  		try(
  			trimmedFile = #()
  			bitmapname = sceneMaterials[i][j].diffuseMap.filename
  			trimmedFile = filterstring bitmapname " \ "
  			bitmapFileName = #()
  			bitmapFileName = filterstring baseFile "."
  			myVal = bitmapFileName.count - 1
  			newfilename = ""
  			for x = 1 to myVal do
  			(
 				newfilename = append newfilename bitmapFileName[x]
 				newfilename = append newfilename "."
  			)
  			finalBitmapName = newfilename + fileFormatType
  			sceneMaterials[i].diffuseMap.filename = finalBitmapName
  		)catch()
  		)
  	)
  	)
  )

The script was designed to work with the diffuse map but should be easy to augment to your needs.

Check out the Renamer script here:

http://www.neilblevins.com/blurscripts/blurscripts.htm

It also lets you search and replace in scene materials.

  • Neil

Hey blue your script didnt seem to work,

now trying the blur scripts

Cheers

It will only work on materials that are assigned to objects in the scene, guess I should have mentioned that. It also strips the path out so you should have the map dir setup in the paths. Like I said it was written a while ago for a large team where this result was required.