Custom confirmation message

The instruction Delete {sourcepath$|noterm} allows you to delete the current folder.

cghgh

But I would like to create a button that allows me to customize this confirmation message, more or less this.

2

Could someone help me write this code correctly? Thank you

function OnClick(clickData)
{
 var dlg = clickData.func.Dlg;
 var cmd = DOpus.Create().Command;

 dlg.title = "Eliminar";
 dlg.message = "Realmente desea eliminar la carpeta" + {sourcepath|nopath|noterm} + "?\n\nArchivos: " +  {tf} + "\nTamaño: " + {sba};
 dlg.icon = "bin";
 dlg.buttons = "&Eliminar|&Cancelar";
 dlg.Show();

 cmd.RunCommand('Delete {sourcepath} QUIET');
}

Seems like a lot of effort just to rearrange the information slightly...

True @Leo, in the end there isn't much difference, just better organized information, the translation of the program into Spanish is sometimes disorganized, and sorry, I didn't know it would take a lot of effort for someone to show me how to delete the current folder from a script, that was really what I wanted, sorry once again.

Your script would have to enumerate the directory and build up a count of different file/folder types and their sizes, if you wanted to do that.

Thanks @Leo, I'm going to study about it

The remaining effort is to calculate the size.

function OnClick(clickData)
{
    var func = clickData.func;
	var sourcepath = func.sourcetab.path;
	var dlg = func.Dlg;
	var cmd = func.Command;
	var fsu = DOpus.FSUtil;

	var arcCount = 0, arcSize = 0;
	var folderEnum = DOpus.FSUtil.ReadDir(sourcepath, "r");
	while (!folderEnum.complete) {
		var folderItem = folderEnum.Next;
		if (fsu.GetType(folderItem) == "dir" && !folderItem.is_dir) {
		    ++arcCount;
			arcSize = arcSize + Number(folderItem.size);
		}
	}
	DOpus.Output(fsu.NewFileSize("s", arcSize/1024/1024))

    dlg.title = "Eliminar";
    dlg.message = "Realmente desea eliminar la carpeta " + func.sourcetab.displayed_label + "?\n\nArchivos: " +  arcCount + "\nTamaño: " + arcSize;
    dlg.icon = "bin";
    dlg.buttons = "&Eliminar|&Cancelar";
    dlg.Show();

    if (dlg.Result)
        cmd.RunCommand('Delete "' + sourcepath + '" QUIET')
}
1 Like

Wow @WKen, you have already helped me so much with this, you don't know how much I appreciate it. I was analyzing that script of yours that I really liked, because I remembered that you had told me that I had to count the files, I am learning a lot with all of you and that makes me very happy, thank you very much once again!

@WKen You will know where I could get the name of the icons available for dlg.icon. I looked in the manual and I couldn't find them, and through the forum I know the name of "info" and "error", but I wanted to know the name of some Recycle Bin, the icon of the toolbar is "gotrash" but it does not work.

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Dialog.htm

1 Like

Now I understand @Jon, dlg.icon only accepts its 4 default icons, many, many thanks!