How can I browse XML Files in the disk and copy it to another disk in MaxScript?

32 Views Asked by At

I am a beginner and just start to learn maxscript. The problems that I met is that how can I browse the xml files in the disk and just copy it and set to another name ,then save it to another disk location? Please can someone help

Does there any function that we can use to copy xml files simply?

2

There are 2 best solutions below

0
Hoser On

You can read and save text-based files (like xml) using FileStream in MAXScript. See the help here: https://help.autodesk.com/view/MAXDEV/2023/ENU/?guid=GUID-BB041082-3EEF-4576-9D69-5B258A59065E

0
DIY_DEV_DESIGN On

to browse contents :

xmlFile = "D:\\test\\test.xml"
f = openFile xmlFile mode:"rt"
while (not eof f) do
(
    cline = readLine f -- to read every single line
    -- enter code here
)
close f

to copy file to oanother location:

-- path_A is original file path , path_B is target location
path_A = "D:\\test\\test_A.xml"
path_A = "E:\\test_B.xml"
-- copy file
copyfile path_A path_B