Has there been a script that is on there that will allow me to switch currently assigned textures to a different format? We received a rather large project with hundreds of textures in .tiff format. The problem is, these textures all totaled are over 3 gigs of memory. I've converted the textures to a more manageable file type, but can I bulk switch them? Say switching them all from .tiff to .jpeg or whatever format we end up going with. The names will stay exactly the same, it's just the file extension.
Forum topic · Scripts Wanted
Changing Texture Format
By VelvetElvis · 2009-09-30
Description
Comments (10)
great
shot3d · 2015-09-28
thx
real08121985 · 2009-12-09
wooooooooooooooooooooooooooooooooooord ;)
Andrue · 2009-12-08
Thanks! YOU ARE THE MAN! I search this script hole day, and now I find it, and it works perfectly! Thank you! Thank you! Thank you!
paulov · 2009-10-02
This morning I was wondering if this could be possible as I found a nice 3d texture maker but it only exports in jpg , tiff tga... and I use dds, but this way I can go mapping all the objets and when I've all the textures converted tu dds do the swap.
THanks for the script!
real08121985 · 2009-09-30
I got the same problem some time ago. Note this script ignores case.
(
local sFrom = "tga" -- previous format
local sTo = "jpg" -- the format that we want
local aBmaps = getClassInstances BitmapTexture
for Bmap in aBmaps do (
local sFilename = Bmap.filename
local sPath = getFilenamePath sFilename
local sFile = getFilenameFile sFilename
local sType = replace (getFilenameType sFilename) 1 1 ""
if toLower sType == toLower sFrom do Bmap.filename = sPath + sFile + "." + sTo
)
)
Changing texture format
ManoloStai · 2011-08-24
Holy Cow!!!!!!!
This is awesome, amazing....
this really really helped
Thank you so much
Great!
3dwannab · 2015-05-10
Is it possible for this to work with changing the filename and not the extension also. Tried to edit what you had but without luck. Thanks.
Got it working
3dwannab · 2015-05-10
This code only trims the filename from the left. I wanted to replace 'Archmodels' with 'AM'. Here's the code. Thanks for a starting point.
ReplacedString = "archmodels" as string
NewString = "AM" as string
patternIs = NewString + NewString + "*"
theMaps = getClassInstances BitmapTexture
for i in 1 to theMaps.count do (
fileName = theMaps[i].filename
newFilename = trimleft fileName ReplacedString
new2filename = NewString + newFilename
if matchPattern new2filename pattern:patternIs ignoreCase:false == false then (
theMaps[i].filename = new2Filename
)
)
barigazy · 2015-05-10
This solution will replace all "archmodels" strings with "AM" only if "AM..." file realy exists.
I did'nt test this but I hope that works ;)
fn replaceFilename currentString: withString: =
(
fn isValidMap map = isKindOf m.filename string and matchPattern m.filename pattern:(currentString + "*")
local maps = getClassInstances BitmapTex
local appendPath = pathConfig.appendPath
if maps.count > 0 do
(
for m in maps where isValidMap m do
(
path = getFilenamePath m.filename
name = filenameFromPath m.filename
if doesFileExist (string = appendPath path (substituteString name currentString withString)) do
(
setProperty m #filename string
)
)
)
)
replaceFilename currentString:"archmodels" withString:"AM"
3dwannab · 2015-05-17
Hi barigazy. Thanks for the code. But it's throwing an error on line fn isValidMap like
-- Error occurred in anonymous codeblock;. I've since get this working with the help of pixamoon over on a seperate thread I created. http://www.scriptspot.com/forums/3ds-max/general-scripting/convert-undef… Here's the code.
OldString = "Arch137" as string -- Change to suit
NewString = "AM137" as string -- Ditto
theMaps = getClassInstances BitmapTexture
for i in 1 to theMaps.count do (
fileName = theMaps[i].filename
if matchPattern fileName pattern:"AM*" ignoreCase:false == false then (
newFilename = trimleft fileName OldString
new2filename = NewString + newFilename
theMaps[i].filename = new2Filename -- renames
)
)One downside of this is it only replaces the first instance of the string but it works well :)