ScriptSpot

Forum topic · General Scripting

choice path button

By kredka · 2013-11-12

Description

I need for my script new window with 15 buttons, if you press it, it will ask you to pick some folder. After this
localisation will be keep and check-update olways whan script is lanch.
Maybe info about localisation should be save to txt file?
When I press another button "DELETE FILES"
files in picked filders and sub folders will be delited. Can anybody help me with this, I can't figure this out by my slef.
It's imporatant that buttons should remember localisation even after max restart.

Comments (5)

kredka · 2013-11-13

still won't work, I checked it already and it do nothing, I don't know why.I wished it work:)

.

miauu · 2013-11-13

Did you read the script?
I did not tell you that you have to create the ini file.
This


local foldersPathIni = "D:\\FolderSettingsIni.ini"

shows where the ini file will be created. Do you have D: drive on your HDD and it is accessable via maxscript(because you can't create files, using maxscript, on C: drive(where mine/your OS is installed)).
So, run the script, go to D: drive and check if you have FolderSettingsIni.ini file.
I can make a video to show you that the code works.
:)

dont work

kredka · 2013-11-13

Thanks a lot, however it wnon't work
Script dont remove anything and dont hold paths after reseting max:) so it's nice code but don't work. Also i would need location patch as text inside button s if You could check it I would be grateful

barigazy · 2013-11-13

Probably the best solution will be .net + xml for storing paths

.

miauu · 2013-11-12

The deleted files and folders can't be restored using the Recycle Bin.
Add as many buttons as you want.


(
	global rol_
	try(destroyDialog rol_)catch()
	rollout rol_ ""
	(
		local foldersPathIni = "D:\\FolderSettingsIni.ini"
		
		button btn_1 "Browse" across:2
		button btn_1_dell "Delete"
		button btn_2 "Browse" across:2
		button btn_2_dell "Delete"
		button btn_3 "Browse" across:2
		button btn_3_dell "Delete"
		
		function SelectFolder btn =
		(
			dir = getSavePath caption:"Select folder" initialDir:(getIniSetting foldersPathIni btn "folder_path")
			if dir != undefined do
			(
				setIniSetting foldersPathIni btn "folder_path" dir
			)
		)
		
		function DeleteFoldersAndFiles dir =
		(
			local dIO = dotNetClass "system.IO.directory"
			if doesFileExist dir do
			(
				try(dIO.delete dir true)catch()			
			)
		)
		
		on btn_1 pressed do
		(
			SelectFolder "btn_1" 
		)
		
		on btn_2 pressed do
		(
			SelectFolder "btn_2" 
		)
		
		on btn_3 pressed do
		(
			SelectFolder "btn_3" 
		)
		
		--//	Delete files
		on btn_1_dell pressed do
		(
			DeleteFoldersAndFiles ((getIniSetting foldersPathIni "btn_1" "folder_path"))
		)
		on btn_2_dell pressed do
		(
			DeleteFoldersAndFiles ((getIniSetting foldersPathIni "btn_2" "folder_path"))
		)
		on btn_3_dell pressed do
		(
			DeleteFoldersAndFiles ((getIniSetting foldersPathIni "btn_3" "folder_path"))
		)
	)
	createdialog rol_ 
)