ScriptSpot

Forum topic · General Scripting

Text File Directory

By Mrjacks2o · 2015-09-05

Description

Hi Everyone i have a simple script that generates a text file.

---------------------Text file--------------------------------

Dir1 = gp_mainPath
out_name = (fileName.text + ".txt")
out_file = createfile out_name
format "%-" ("D")to:out_file
format "%-" (print polyList.count/257)to:out_file
format "%" (Stonecount.text = RStyle2.text)to:out_file

---------------------Text file--------------------------------

i figured out how to generate the text name but cant set the directory to gp_mainPath

any help will be appreciated.

thanks

Comments (6)

Mrjacks2o · 2015-09-06

1

.

miauu · 2015-09-05

Something like this:


(
	
gp_mainPath = "D:\\test_folder\\"
out_name =	gp_mainPath + (fileName.text + ".txt")
out_file = createfile out_name
format "%-" ("D")to:out_file
format "%-" (print polyList.count/257)to:out_file
format "%" (Stonecount.text = RStyle2.text)to:out_file

---------------------Text file--------------------------------
)

Mrjacks2o · 2015-09-05

thanks for the quick reply the problem with that script is it adds the last folder name to the file name.

so lets say "C:\\Users\Workstation\\Documents\\3dsMax" is my directory and i put the name test it generates "3dsMaxtest.txt" as the name and places it in a  folder "C:\\Users\Workstation\\Documents\\

thats why i am trying to remove the direcotry from the out_name

any idea how to fix it? 

.

miauu · 2015-09-06

If I understand you correctly you want to save the file one llevel up, not in the last fgolder, but in the folder that contains the last folder.


pathConfig.removePathLeaf "c:\\temp\\test"
-- the result is
"c:\temp"

Great thanks

Mrjacks2o · 2015-09-06

1 last question how can i add a new line in the text file for this code. format "%-" ("SP")to:out_file

like this
D-20-40
SP

Not like this
D-20-40 SP

`

pixamoon · 2015-09-06

just "\n" character

format "%-\n" ("SP")to:out_file