Purpose
Delete a folder

Solution
Use a JavaScript or VB call to delete a whole folder. The GuiXT RemoveFile statement cannot be appilied to folders.

Example 1
The following JavaScript function removes the folder with the given name.

Attention:
- The folder will be deleted with its entire contents and any subdirectories
- The files cannot be restored via the Recycle Bin
- No prompt for confirmation will appear
- Placeholders + and * may be used to delete multiple folders

function delete_folder(foldername) {

    var fso = guixt.CreateObject("Scripting.FileSystemObject");
 
   
// folder exists ?
    if (!fso.FolderExists(foldername)) return " ";
 
   
// delete folder
    fso.DeleteFOlder(foldername);
 
   
return "X";
}

GuiXT script:

CallJS
delete_folder "C:\temp\todelete"   

 

Example 2
The following JavaScript function removes files and subfolders with the given name, putting them into the Recycle Bin.

function delete_file(foldername, itemname) {
   
var shell = guixt.CreateObject("Shell.Application");
   
var folder = shell.NameSpace(foldername);
   
var item = folder.ParseName(itemname);

    item.InvokeVerb('delete');
}

GuiXT script:

CallJS delete_file "C:\temp"  "todelete" 

 

Components
InputAssistant + Controls