Here's a script-button which will find the correct folder (2 levels below the current folder), move it up to the current folder, and (if they are now empty) delete the two intermediate folders.
You will need to edit the top of the script to specify the 1st and 3rd folder names:
var FirstFolder = "Named SubFolder";
var NeededFolder = "Needed Folder";
If there is more than one folder under the 1st one, the script will exit without moving or deleting anything. (You could make it display an error dialog if you want.)
Button in .DCF format:
Full script code contained inside the .dcf file, for reference:
function OnClick(clickData)
{
var FirstFolder = "Named SubFolder";
var NeededFolder = "Needed Folder";
var cmd = clickData.func.command;
cmd.deselect = false; // Leave original selection alone.
cmd.ClearFiles(); // Ignore original selection.
// Resolve is important for special folders like /Desktop
var resolvedSource = DOpus.FSUtil.Resolve(clickData.func.sourcetab.path);
var pathFirstFolder = DOpus.FSUtil.NewPath(resolvedSource);
pathFirstFolder.Add(FirstFolder);
var pathSecondFolder = DOpus.FSUtil.NewPath();
var gotSecondFolder = false;
var folderEnum = DOpus.FSUtil.ReadDir(pathFirstFolder);
while (!folderEnum.complete)
{
var folderItem = folderEnum.Next();
if (folderItem.is_dir)
{
if (gotSecondFolder)
{
return; // Too many folders.
}
gotSecondFolder = true;
pathSecondFolder.Set(folderItem.RealPath);
}
}
var pathNeededFolder = DOpus.FSUtil.NewPath(pathSecondFolder);
pathNeededFolder.Add(NeededFolder);
if (DOpus.FSUtil.GetType(pathNeededFolder) != "dir")
{
return; // Needed folder doesn't exist, or it's a file.
}
// DOpus.Output(pathNeededFolder);
cmd.AddLine('Copy MOVE FILE="' + pathNeededFolder + '" TO="' + resolvedSource + '"');
// Do not remove "NORECYCLE" or the "FAILNOTEMPTY" won't work.
cmd.AddLine('Delete QUIET NORECYCLE FAILNOTEMPTY FILE="' + pathSecondFolder + '"');
cmd.AddLine('Delete QUIET NORECYCLE FAILNOTEMPTY FILE="' + pathFirstFolder + '"');
cmd.Run();
}