Hi everyone,
This script opens two subfolders (Images + Videos) in dual horizontal mode. The problem is that it doesn't open the subfolders if one of them is empty. It's because the script relies on dirtype: No video in the subfolder - no video folder. What if I used "dirName" instead of "dirType". I always name my subfolders like My Images and My videos. I'm not good at javascript. Maybe, there is someone who knows how to do it. Thanks
function OnClick(clickData)
{
var imgDir = null;
var vidDir = null;
//enumerate the directories (looking for image and video folders)
for (var dirEnum = new Enumerator(clickData.func.sourcetab.dirs); !dirEnum.atEnd(); dirEnum.moveNext())
{
var dirItem = dirEnum.item();
var dirType = GetDirectoryType(dirItem);
Log(dirItem + " is type " + dirType);
//check if weve got directories already, else assign htem
if(!imgDir && dirType == "image")
imgDir = dirItem;
if(!vidDir && dirType == "video")
vidDir = dirItem;
//if both found, stop here
if(imgDir && vidDir)
break;
}
//if both found
if(imgDir && vidDir)
{
Log("found");
var cmd = clickData.func.command;
cmd.AddLine("Set VIEW=Thumbnails");
cmd.AddLine("Go \"" + imgDir + "\" DUALPATH \"" + vidDir + "\"");
cmd.Run();
}
else
Log("nothing found");
}
//check which files are in dir, if one matches video or img, return this
function GetDirectoryType(dir)
{
var folderEnum = DOpus.FSUtil.ReadDir(dir);
while (!folderEnum.complete)
{
var item = folderEnum.Next();
if (!item.is_dir)
{
if(item.InGroup("Images"))
return "image";
if(item.InGroup("Movies"))
return "video";
}
}
}
function Log(msg){DOpus.Output(String(msg));}
I assume with simultaneously you mean one folder shown left/upper and the other one in right/bottom display.
If you have for example "C:\MyImages", then enter this path under "folder" for left display, and the other one "D:\MyVideos\ for right one. Or tell DO to use register-groups if you prefer register.
What if I have a lot of folders from my world travel with names of towns I have visited. Let's say "D:Paris\MyVideos" "C:Paris\MyImages" and "D:Berlin\MyVideos" "C:Berlin\MyImages" and etc. It seems it can't deal with parent folders which are variables in my case
Maybe, we misunderstand each other, Sasa. The parent folders (countries) are different in my case and they are not the same, whereas the names of the 2 subfolders are always the same (My images and My videos). Idk how to enter the correct path under "folder", since the parent folders are not the same. I tried something like this C:\..\MyImages. Doesn't work
If the sub-folder names are always the same, and you want to open both of them in the same way regardless of contents (even if they are empty), why is the script even looking inside the two folders? It could just open the two folders without that part.