ScriptSpot

Forum topic · General Scripting

reducing save path

By turbinea · 2009-10-09

Description

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 (5)

turbinea · 2009-10-26

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

oldFilePath= "D:\Test_Area\T

Kstudio · 2009-10-16

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

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

Marco Brunetta · 2009-10-16

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

( fn reduceFolder thePath

Marco Brunetta · 2009-10-12


(
	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 · 2009-10-10

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