Save to same location + subfolder and another small question

Hi Guys,

This is my first post here. I am just getting started with Maxscript and trying a number of smaller scripts to slowly ease my way in, but give a good idea on script structure etc. So far going well, but hit a bit of a stumbling block.

Say I am working in a folder with parental status (top folder). I want to same to this location + a named folder. I would like the name to be the current maxfile name + "_xyz holder".

Below is where i got stuck. This only looks to save to the same location. I would like to save to maxFilePath\\subfolder\\currentMaxfilename + b + .max

example =(currentMaxfilename + b + .max) actual name = maxfile_xyz holder.max

This is where I have got quite stuck.

b = "_xyz holder"
currentName = getFilenameFile()
saveMaxfile(sceneName)
sceneName = maxFilePath + currentName + b + (extension (.max))

On a separate note is it possible to prompt the user to save a maxfile on the start of a script. Another idea I'm playing with needs to ask the user if they would like to save there current maxfile before the script carries out another function on the current file, more of a peace of mind buffer. Struggling to find any info on it?

Many thanks for the help!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

an example

run the code line by line to see what each line do ;)

checkForSave() -- ask the user to save
 
baseName = getFilenameFile (maxFilePath + maxFileName)
newName = baseName + "_xyz holder.max"
 
subDir = maxFilePath + "mySubFolderName"
If not doesFileExist subDir do makeDir subDir
 
savePath = subDir + "\\" + newName

my recent MAXScripts RSS (archive here)

ce89's picture

Anubis,Many thanks for the

Anubis,

Many thanks for the quick reply. I have ran the code line by line as you suggested. This is very helpful to see what each code block does.

The only thing I cant work out is that is does not seem to actual save a new file with the newly created filename and location. Is there another bit I need to add to actual make it save the file to that location.

EDIT: I have just worked it out. Many thanks for your help Anubis, much appreciated.

ce89's picture

Sorry Anubis,That work

Sorry Anubis,

That work great, but when I ran a few back to back versions it kept making a subfolder each time (as it is instructed to do). I am now trying to get the script to check its parent level group name. If this is equal to "subfolder" then it knows to save in this location. If not then it should work as before and create a new subfolder named "subfolder" and create the new file in there as before.

Hope this makes sense. I am struggling to work out how to check the cureent location parent set name. I have included an idea of what I am trying to achieve below.

Many thanks again.

checkForSave() -- ask the user to save
baseName = getFilenameFile (maxFilePath + maxFileName)
newName = "box_red.max"

if maxFilePath parent set name == "subfolder" do (
savePath = maxfilePath + newName
savemaxfile (savePath)
)
else (
subDir = maxFilePath + "subfolder"
If not doesFileExist subDir do makeDir subDir

savePath = subDir + "\\" + newName
savemaxfile (savePath)
)

Anubis's picture

not very clear...

Well, I can't protect you from logical mistakes :) Once you save your scene with saveMaxFile(savePath) the new saved scene become currently loaded. So if you run the script again on that scene, then of course it will made a new sub-folder. If the goal is to make multiple copies of the same scene then use saveMaxFile function with the optional parameter - useNewFile:false, i.e. -
saveMaxFile savePath useNewFile:false
(check the help file for details).

my recent MAXScripts RSS (archive here)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.