"Save as" script that will set an output path and add a prefix and a suffix

"Save as" script that will set an output path and add a prefix and a suffix

Anonymous
Not applicable
3,895 Views
8 Replies
Message 1 of 9

"Save as" script that will set an output path and add a prefix and a suffix

Anonymous
Not applicable

Hello All,

 

I'm very new to maxscript but I have a ton of knowledge with 3ds max. I'm wondering if there's a way to create a script that will allow me to run a saveas command to a specific folder/path that can have a specific prefix and suffix.

 

For example, I'm saving a ton of files that all need to have the prefix "HQ_(nameofthefile)"-2017" With the prefix being "HQ_" and the suffix being "-2017" I hope that makes sense. It seems like it would be fairly simple to do if you have a little scripting experience (which I do not, lol!) I would then turn that script into a button which could be pressed for each file that I open.

 

If anyone can help I would greatly appreciate it!

0 Likes
Accepted solutions (1)
3,896 Views
8 Replies
Replies (8)
Message 2 of 9

har1sf0x
Advocate
Advocate

Hello,

 

  This macro should work:

 

macroScript SaveAsHQ2017
category:"har1sf0x Tools"
tooltip:"Save As HQ_...-2017"
buttontext:"HQ_"
(
  on execute do
  (
filePath = maxFilePath -- or enter your filePath @"C:\MyFolder\" sceneName = filePath + "HQ_" + maxFileName + "-2017" saveMaxFile sceneName quiet:true ) )

 

Enjoy,

har1sf0x

Message 3 of 9

Anonymous
Not applicable

Thank you so much! I entered the macroscript just like below with my path but I keep getting this error. I must not be entering it correctly. Any thoughts?

 

macroScript SaveAsHQ2017
category:"har1sf0x Tools"
tooltip:"Save As HQ_...-2017"
buttontext:"HQ_"
(
on execute do
(
filePath = L:\5D Reference Library\03_3D\3DMAX\Models\Landscaping\Trees\Broadleaf
sceneName = filePath + "HQ_" + maxFileName + "-2017"
saveMaxFile sceneName quiet:true
)
)
-- Syntax error: at ), expected <factor>
-- In line: )

 

0 Likes
Message 4 of 9

miauuuu
Collaborator
Collaborator
filePath = @"L:\5D Reference Library\03_3D\3DMAX\Models\Landscaping\Trees\Broadleaf"
https://miauu-maxscript.com/
Message 5 of 9

Anonymous
Not applicable

Okay so I stripped the code down to this and saved as a .ms on my desktop. When I run the script it says it's saving now but it's not saving to the path specified or with the prefix or suffix...But at least it's not giving me errors anymore. Any more ideas to make this work? Thanks again!!!

 

...see attached screenshot

0 Likes
Message 6 of 9

miauuuu
Collaborator
Collaborator
Accepted solution
on execute do
(
	filePath = @"L:\5D Reference Library\03_3D\3DMAX\Models\Landscaping\Trees\Broadleaf"
	sceneName = filePath + "\\HQ_" + ( getFilenameFile maxFileName) + "-2017.max"
	saveMaxFile sceneName quiet:true
)
https://miauu-maxscript.com/
0 Likes
Message 7 of 9

Anonymous
Not applicable

Thank you so much!!! It's working! Is there a reason why getting rid of "on execute do" made it work?

 

The final code looks like this: 

 

(

(
filePath = @"L:\5D Reference Library\03_3D\3DMAX\Models\Landscaping\Trees\Broadleaf"
sceneName = filePath + "\\HQ_" + ( getFilenameFile maxFileName) + "-2017.max"
saveMaxFile sceneName quiet:true
)
)

0 Likes
Message 8 of 9

har1sf0x
Advocate
Advocate

Hello there,

 

  As i said that was a macro (.mcr not .ms) and there was a comment about the path address showing that you have to use @ and "". You should check the help file sometime (link for macroscript) it is really useful 😉

 

Enjoy,

har1sf0x

0 Likes
Message 9 of 9

Anonymous
Not applicable

Thanks har1sf0x! Will do. I'm still very new at maxscript and I'm trying to learn. Thanks for the recommendation. I will definitely check it out.

0 Likes