Hey everyone. I've been learning MAXScript for the past month and I am making something that allows a user to select a file in a Directory, copy/cut it and paste said file in a new specifiied directory. I think I've managed to get as far as showing a dialog rollout with a Browse function for the file I want to select and to select the directory I want to paste it in. The problem now is how exactly can I copy/paste the file, essentially emulating Window's "Copy" "Paste" feature within a MAXScript file? The file I'm trying to copy is an .mse file, so copying contents is essentially null.
I've tried copyFIle() but as far as I understand all it does is copy the contents from file A and write them in file B, which is not what i want.
I've also looked at DOSCommands but its copy function does not seem to be working correctly. Is there something I should be looking for or am missing?
It doesn't give me any error or anything, it simply just quickly flashes a window and does nothing.
I'll paste the snippet of the code in question ^^
Thank you in advance!
--------------------------- CODE SNIPPET-----------------------------------
(
-------------------------------- GUI --------------------------------
Global mseFileDir = ""
Global mseFileName = ""
Global mcrFolderDir = ""
Global mcrFileName = ""
rollout msePaths "MSE File"
(
-- Rollout UI
editText mse_path "" labelOnTop:true
button btn_mseBrowse "Browse..." width:100 height:20 align:#left
-- End Rollout UI
-- UI Functionality
on btn_mseBrowse pressed do
(
mseFilePath = ""
mseFileName = ""
mseFilePath = getOpenFileName caption:"Open File" types:"MSE(*.mse)|*.mse|"
if (mseFilePath != undefined) do
(
mse_path.text = mseFilePath
mseFileName = filenameFromPath mseFilePath
)
if (mseFilePath != undefined) do
(
append mseFileDir mseFilePath
)
print (mseFileDir)
print (mseFileName)
)
-- End UI Functionality
)
rollout mcrPaths "Macroscript Folder"
(
-- Rollout UI
editText mcr_path "" labelOnTop:true
button btn_mcrPathBrowse "Browse..." width:100 height:20 align:#left
-- End Rollout UI
-- UI Functionality
on btn_mcrPathBrowse pressed do
(
mcrFolderPath = ""
mcrFolderPath = getSavePath()
if (mcrFolderPath != undefined) do
(
mcr_path.text = mcrFolderPath
append mcrFolderDir (mcrFolderPath)
mcrFileName = mseFileName + ".mcr"
)
print (mcrFolderDir)
print (mcrFileName)
)
-- End UI Functionality
)
rollout scriptApply "Apply"
(
-- Rollout UI
button btn_Apply "Apply" width:100 height:20 align:#left
-- End Rollout UI
-- UI Functionality
on btn_Install pressed do
(
if (mseFilePath != undefined and mseFileName != undefined and mcrFolderPath != undefined) do
(
messageBox("MSE File is: " + mseFileName + " and MCR Folder Path is: " + mcrFolderPath)
DOSCommand ("copy " + mseFileName + " " + mcrFolderDir)
)
)
-- End UI Functionality
)
scriptApply = newRolloutFloater "Copy and Paste" 420 220
addRollout msePaths scriptApply
addRollout mcrPaths scriptApply
addRollout scriptInstall scriptApply
)
Replies
(
-------------------------------- GUI --------------------------------
Global mseFileDir = ""
Global mseFileName = ""
Global mcrFolderDir = ""
Global mcrFileName = ""
rollout scriptApply "Apply"
(
local mseFilePath = undefined
local mseFileName = undefined
local mcrFolderPath = undefined
editText mcr_path "" labelOnTop:true
button btn_mcrPathBrowse "Browse..." width:100 height:20 align:#left
editText mse_path "" labelOnTop:true
button btn_mseBrowse "Browse..." width:100 height:20 align:#left
-- Rollout UI
button btn_Install "Apply" width:100 height:20 align:#left
-- End Rollout UI
-- UI Functionality
on btn_mcrPathBrowse pressed do
(
mcrFolderPath = ""
mcrFolderPath = getSavePath()
if (mcrFolderPath != undefined) do
(
mcr_path.text = mcrFolderPath
append mcrFolderDir (mcrFolderPath)
mcrFileName = mseFileName + ".mcr"
)
print (mcrFolderDir)
print (mcrFileName)
)
on btn_mseBrowse pressed do
(
mseFilePath = ""
mseFileName = ""
mseFilePath = getOpenFileName caption:"Open File" types:"MSE(*.mse)|*.mse|"
if (mseFilePath != undefined) do
(
mse_path.text = mseFilePath
mseFileName = filenameFromPath mseFilePath
)
if (mseFilePath != undefined) do
(
append mseFileDir mseFilePath
)
print (mseFileDir)
print (mseFileName)
)
on btn_Install pressed do
(
format "mseFilePath: % \n" mseFilePath
format "mcrFolderPath: % \n" mcrFolderPath
-- if (mseFilePath != undefined and mseFileName != undefined and mcrFolderPath != undefined) do
-- (
-- messageBox("MSE File is: " + mseFileName + " and MCR Folder Path is: " + mcrFolderPath)
copyFile mseFileName (mcrFolderPath + "\\" + mseFileName)
-- )
)
-- End UI Functionality
)
createDialog scriptApply
-- scriptApply = newRolloutFloater "Copy and Paste" 420 220
-- addRollout msePaths scriptApply
-- addRollout mcrPaths scriptApply
-- addRollout scriptInstall scriptApply
)