convert: undefined to type: String PROBLEM [SOLVED]
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 ) )
The above creates an error stated in the subject. I have tested this on 20+ scenes prior without any errors. I want to achieve is to replace 'string1' for 'string2' in the filename paths whilst not affecting the actual path.
As I've said it worked on 20 odd scenes prior.
Thanks for any help.
Comments
Regexpression example (Greaaaat success - Borat)
Strips filenames and paths only if missing from scene :) (much like relink bitmaps by colin senner)
FINISHED CODE (Case sensitive)
Code error in last code snippet NEW CODE HERE...
Listener output:
`
Hello again :) maybe something like this:
or just minimum addition to your code:
Hiiii, No...
First code you wrote still has that same error.
I've fixed the problem in my original code where it was replacing part of the filename with this particular scene by using 'fileName = (getfilenamefile theMaps[i].filename)' as opposed to 'fileName = theMaps[i].filename' but the error still crops up.
Full output from the listener using code:
Listener:
BTW do you know why the listener stops outputting when you run evaluate or eval selected line/code. Have to restart max to get it working.
I can send the test scene if you're willing to help. The way I want the format of the jpgs filenames is 'AM66_*.jpg' so the pattern would need to match 'AM' 'digits' 'underscore' 'anychar' 'ext'. Maybe I'm tired learning maxscript but I can't figure it out, plus the error which is more important.
Getting this to work would be a great timesaver. I tried looking for wxample codes also where say I want:
OldString = "Arch137" as string -- Change to suit
to allow different options that support wildcards. I know this is asking a lot. :)
MANY THANKS FOR HELPING SO FAR.
`
yes sure please send it.
But for renaming files or bitmap filenames in project you can use my Bitmap Tracking/Resizing... or cbuelter't Interactive Renamer
And yes, I know that "listener stops working" I had similar thing many times. What I found out only: it happens mostly if there is mistake in code and than it can't evaluate it or show error.
If I remember sometimes helps to delete what I changed last or try maybe to delete whole code, evaluate only with a = 1 and than undo detete ?? just an idea
also u have undefined error in other line:
new code:
or
FOUND A SOLUTION TO THE LISTENER NOT WORKING
Place the cursor in the listener and hit escape a couple of times. :]
:{([
Neither of those codes worked. I'm stumped. Sending scene and thanks for the trick. I tried evaluating a line of code I know was okay but I'll try your method next time. Don't mind the state of the scene I decimated the model.
`
:( I don't have 2015 to test it
But looked in the the file with Library Track/Relink. And could see your assets list.
I test names in new scene with this new code:
Sorry I didn't noticed this before - you had:
if matchPattern fileName pattern:"AM*" ignoreCase:false == false then
It was trying to trim and rename all files other then "AM*"
I think it should look for oldString to machtpattern. Than will try to trim only files you want to rename...
if fileName != undefined and matchPattern fileName pattern:(OldString+"*") ignoreCase:false then
Also for renaming you can use Bitmap Tracking Resizing or Library Track/Relink...
They have much more options to rename files in proj or on HDD etc.
Just a small screenshot how to replace in filename:
Thanks, the idea behind this
Thanks, the idea behind this .ms file is to run it with Batch it max over multiple directories and therefore saving tonnes of time in the long run :)
So far I've done a script to clean the assets how I like them found here: http://www.scriptspot.com/3ds-max/scripts/asset-cleaner minus the UI of course to work with BatchItMax and rename objects based on 'Filename + node type' and others like using relink bitmaps to find missing maps. and of course filter set to none and blur to 0.0. Things I find myself doing all the time on an individual basis.
Thanks for spotting the AM. I could replace that with:
pattern:("*"+OldString+"*")
to search that string anywhere in the string replacing any instances of it. I'd love if I could get regular expressions to work seeing as I know how to do that :) but maxscript is a different league but baby steps, baby steps. I've attached the scene in '14 format.
The new code is still throwing an error at:
fileName = (filenamefrompath o.filename)
Bangs head!!