There you go.
I added the QUIET option otherwise, you get a confirmation request for every file to delete.
It's in JScript, since I got used to it more than VB recently
function OnClick(clickData)
{
//DOpus.ClearOutput();
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// --------------------------------------------------------
cmd.RunCommand("Set VIEW=Details");
// --------------------------------------------------------
DOpus.Output("Selected items in " + clickData.func.sourcetab.path + ":");
if (clickData.func.sourcetab.selected.count == 0)
{
DOpus.Output("Nothing to do (no selected folder). Exiting.");
return;
}
var matchingFiles = DOpus.Create.Vector();
for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
{
if (eSel.item().is_dir)
{
var folderEnum = DOpus.FSUtil.ReadDir(eSel.item(), "r");
while (!folderEnum.complete)
{
var folderItem = folderEnum.Next();
if (!folderItem.is_dir && folderItem.ext == ".rpp-bak")
matchingFiles.push_back(folderItem);
}
}
}
DOpus.Output("Matching files (#" + matchingFiles.count + "):");
for (var e = new Enumerator(matchingFiles); !e.atEnd(); e.moveNext()) {
DOpus.Output(">> " + e.item());
cmd.AddLine('DELETE NORECYCLE QUIET "' + e.item() + '"');
}
cmd.Run();
}
Copy/Paste and enjoy deleting Reaper backup files (as an Ableton user, I don't do that ).
If you add the files to a command object (clear the existing files first, if it's the command object the script is given by Opus) and then run the delete command on them, you can avoid that, and also avoid creating some extra objects.
Many thanks for this.
As a matter of interest, is there any way of setting the context for the command using the folder selected in the folder tree - e.g. for the Trax217 folder in the screenshot below (rather than having to select a folder in the list view). This was what I was originally trying to achieve, as it better matches the way that I work:
Right !! That's what I tried first, but got folder deletion. I thought it was the same behaviour as in the previous script, but of course, it's just that I forgot to remove the already selected files in the command object. Changed in this new version below.
In that case, no need to act on every selected folder, starting from the path of the sourcetab should do the trick. It even makes the script more simple.
New version with both changes :
function OnClick(clickData)
{
//DOpus.ClearOutput();
// --------------------------------------------------------
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// --------------------------------------------------------
cmd.RunCommand("Set VIEW=Details");
// --------------------------------------------------------
var matchingFiles = DOpus.Create.Vector();
DOpus.Output("Searching for .rpp-bak files in :" + clickData.func.sourcetab.path);
var folderEnum = DOpus.FSUtil.ReadDir(clickData.func.sourcetab.path, "r");
while (!folderEnum.complete)
{
var folderItem = folderEnum.Next();
if (!folderItem.is_dir && folderItem.ext == ".rpp-bak")
matchingFiles.push_back(folderItem);
}
DOpus.Output("Matching files (#" + matchingFiles.count + "):");
cmd.ClearFiles();
cmd.AddFiles(matchingFiles);
for (var e = new Enumerator(matchingFiles); !e.atEnd(); e.moveNext()) {
DOpus.Output(">> " + e.item());
}
cmd.RunCommand("DELETE NORECYCLE");
}
function OnClick(clickData)
{
var cmd = clickData.func.command;
cmd.ClearFiles();
var folderEnum = DOpus.FSUtil.ReadDir(clickData.func.sourcetab.path, "r");
while (!folderEnum.complete)
{
var folderItem = folderEnum.Next();
if (!folderItem.is_dir && folderItem.ext == ".rpp-bak")
cmd.AddFile(folderItem);
}
if (cmd.filecount > 0)
cmd.RunCommand("Delete NORECYCLE");
}