Copy file A to B

I try to copy file from place A to place B, I tough it should be dead easy like
copy from "c:/temp/my.text" to "d:/temp/my.text" but it's not so easy.
I have to copy 3dsmax.ini file, first check where it is(is usually under user/appdata etc so I cant use straight path because user name path) then copy this ini to "c"\temp" and I have to do with one more file, then I must delete oryginal ini. I'm not skilled in maxscript so I want keep code as simple as possible. I would be grate full some clue, I already search in max help but I don't get how to do it. It's really simple operation. The code is below but it doesn't work.

fn getFilesRecursive root pattern =
(
dir_array = GetDirectories (root+"/*")
for d in dir_array do
join dir_array (GetDirectories (d+"/*"))
my_files = #()
for f in dir_array do
join my_files (getFiles (f + pattern))
my_files
)
-- get filepath for 3dsmax.ini
INIname=getFilesRecursive "c:/users" "3dsmax.ini"
INInameb=getMAXIniFile()

-- name for new folders
mdfilepatA="C:\temp\1"
mdfilepatB="C:\temp\2"

-- check if 3dsmax ini exist, if exist then do
INIexistmd=INIname as string
if INIexistmd=="#()" then
(
-- if txt file don't exist then
messagebox "There is no ini file to copy"
---- create openlog
)
else
(
messagebox "start"

--create directory
makeDir @"C:\temp\1" all:false all:false
makeDir @"C:\temp\2" all:false all:false
-- copy files
copyFile INIname mdfilepatA
copyfile INInameb mdfilepatB
--deleteFile oryginal ini file
deletefile INIname
deletefile INInameb

)

Comments

Comment viewing options

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

thanks, according to miauu

thanks, according to miauu you are absolutely right but I want my script work on other compters so I have to know not only how it works on my computer but how it work in general

miauu's picture

.

In this case you have to know how the script works with different version of 3ds Max. For example I always test my scripts on max9, 2009, 2012, 2013, 2014 to be sure that there are no errors between the versions.

miauu's picture

.

The only way to check which INI affect current 3dsMAx is to:
- delete the first INI (from your list). Restart Max. See what is happens.
- delete the next ini. restart max, see what is heppens
- and so on.

At the end you will know which INI file affects which settings of 3ds Max.

kredka's picture

Ini 3

so I checked where all max ini files are and:

"C:\Users\\Documents\3dsMax\archives"
#("c:\users\\\Documents\\3dsMax\\archives\3dsmax.ini", "c:\users\\\AppData\\Local\\Autodesk\\3dsMax\\2013 - 64bit\\ENU\3dsmax.ini")
"c:\users\\\Documents\\3dsMax\\archives\3dsmax.ini"
"c:\users\\\AppData\\Local\\Autodesk\\3dsMax\\2013 - 64bit\\ENU\3dsmax.ini"
"C:\Program Files\Autodesk\3ds Max 2013\en-US\3dsmax.ini"
"C:\Program Files\Autodesk\3ds Max 2013\en-US\3dsmax.ini"
"C:\Program Files\Autodesk\3ds Max 2013\en-US\3dsmax.ini"

according to maxscript getMAXIniFile() indicate:
"C:\Program Files\Autodesk\3ds Max 2013\en-US\3dsmax.ini"
as current ini

but regarding to Autodesk recommendation

http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=1409599...

current ini is there
c:\users\\\AppData\\Local\\Autodesk\\3dsMax\\2013 - 64bit\\ENU\3dsmax.ini

so which ini effecting current max?
I'm confused with this.

kredka's picture

INI 2

This is about ini from Autodesk:
http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=1409599...

and they recommend to change ini file in
Windows 7/Vista:
C:\Users\\AppData\Local\Autodesk\3dsmax\\enu

however getMAXIniFile() gives me C:\Program Files\Autodesk\3ds Max 2013\en-US\3dsmax.ini
so where is right ini to effect on max?

kredka's picture

Ini

Thanks all of you for help, but let's talk a little about how to handle better with max settings.

so code from miauu is very helpful:
(
bkpDir = if (maxVersion())[1] >= 9000 then (GetDir #archives) else (GetDir #autoback)
bkpFile = bkpDir + "\\3dsmax.ini"
iniFile = getMAXIniFile()
if doesFileExist bkpFile do deleteFile bkpFile
copyFile iniFile bkpFile
)

And it copy ini files into archive max folder.
This script is only one way ini to --> backups
but there should be second way backup ---> to ini

But if you have no backups of your ini then in order to reset max settings you have to remove ini(or maybe 3dsmax.ini additional defoult copy is somewhere under max folders to restore it and my all issue make no sense?). From what I remember from older versions after removing 3dsmax.ini, max after next start created this 3dsmax.ini by it self with defoult settings. There was no problem at all. Now I test it on 3dsmax2013 and 3dmax.ini is indeed selfcreated however it seems new ini don't effect on 3dsmax. All elements, macros, Ui, previous scene etc.. all settings are still there. Why?
Second thing I found removing Plugin.UserSettings.ini in deed reset max settings but cause some problems like it keep access to some of old macros but it don't know where it is etc. Third thing is: there is 3dsmax.ini under
C:\Users\\AppData\Local\Autodesk\3dsMax\2013 - 64bit\ENU\
but it seems also don't effect max. Next stuff - there is lots of others ini files under max foler for I guess keeping settings for different components of 3dsmax. So my question is, which ini file should be removed or replaced to restore or reset 3dsmax main setting?

miauu's picture

.

This script, from Anubis, is for making a backup of max INI file.

Try to adapt it to fit your needs.

kredka's picture

copy and remove main max settings

I want copy and then remove max ini file which is responsible for kipping all settings and affecting 3dsmax in case of max will start geting crazzy I could just simply push button and clear Max. It could be all ini files if it don't mess up max, other wise only main ini for general main settings.

Then I need separate action to copy old ini files back to oryginal locations, so two options:

fisrt action
copy all ini to c:\temp, delete old

second action
copy ini from c"\temp to theirs oryginal locations

barigazy's picture

...

Messing with the files especially software files is too dangerous via mxs, you know. Also not all *.ini files are placed in the maxroot dir.
If you want to play with this do it manually not by using code. I can help you with other stuffs but this ... I don't want to destroy your PC :) Sorry

bga

barigazy's picture

...

Yup. Kostadin is right.
BTW I will use XML for storing all paths and .net File.Move method.

bga

Comment viewing options

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