reducing save path

hi guys,

i'm trying to create new save path for maxfile. when i get maxfilepath i would like to reduce last, maybe last two folders in path

e.g.

"D:\Test_Area\TestProject\Scenes\subfolderA\"

to

"D:\Test_Area\TestProject\Scenes\"

the idea is to take path and reduce it, and then attach new folder name at the end and create the new path.

"D:\Test_Area\TestProject\Scenes\subfolderB"

I tried to filterstring array and delete last part but dont know how again assemble content of the array into something that can  be used as string for save path

can you plz help me? 

Thanx,
Jan

 

Comments

Comment viewing options

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

Thanx guys, you've been most

Thanx guys, you've been most helpful. Thanx again!!! Laughing

Kstudio's picture

oldFilePath= "D:\Test_Area\T

oldFilePath= "D:\Test_Area\TestProject\Scenes\subfolderA"

newPath = (pathConfig.removePathLeaf  oldFilePath) + "\subfolderB"

Marco Brunetta's picture

Cool, I didn't know about

Cool, I didn't know about the pathconfig struct... thanks!

Marco Brunetta's picture

( fn reduceFolder thePath

(
	fn reduceFolder thePath cutFolders =
	(
		local stringArray = filterstring thePath "\\"
		local newPath = ""
 
		FOR stringIndex = 1 to stringArray.count-cutFolders DO
		(
			newPath += (stringArray[stringIndex]+"\\")
		)
		newPath
	)
)

The function in there should do what you want. Just feed it the path and the number of folders you want to cut.

(
	local theFilePath = "D:\\Test_Area\\TestProject\\Scenes\\subfolderA\\"
	local newFilePath = reduceFolder theFilePath 1
	print newFilePath
)
Anubis's picture

Look for getSaveFileName()

Look for getSaveFileName() function in MXS Reference - "Standard Open and Save File Dialogs" topic.

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.