Can a script do a custom search of a directory/folder

Hello Everyone,

I've just discovered Directory Opus. I was wondering if this "custom search then open a directory" idea of mine is possible with a script.

All our projects are in our "P" drive. We associate our project numbers with the year (last 2 digits) we started the project and the order it was started (3 digits).

Examples:
19001 means P:\2019\001
21007 means P:\2021\007

Is it possible for a script to..

  1. Open a dialogue box.
  2. If I type five characters like “22015”.
  3. Lister will browse/open/jump to P:\2022\015.

If an opus script can do this it would save me a lot of time. I just need a quick answer before I start on my journey of learning how to write a script. (Even with no programming experience).

Thanks in advance.

1 Like

Yes.

If you are ok with two dialogs, you don't even need a script:

Go PATH=P:\20{dlgstring|Enter 2 digits}\{dlgstring|Enter 3 digits}

Ixp,

Yes, I am okay too with 2 dialogs. Thank you.

But I feel a little embarrassed. I’m really new with Opus Directory.
I’m not sure what to do next. If you don’t mind, can you please post
a link for instructions. Or which part of the help manual I start looking.
I have it open now.

Thanks again.

The menus at the top of the site should have what you need:

Leo & Ipx,

Thank you so much!. This really helps me a lot...Now my goal is try
to try make one dialog box.

Thanks again.

Hello Experts,

I'm on a trial version. This search method is almost exactly how my office is setup. I have no coding experience. Can somebody please post a script that has one dialog box. I really would appreciate it..

Thanks.

1 Like

That's too much work for someone to do if you haven't bought Opus.

Hi Leo,

I would buy it in a heart beat if my request is granted. This saves me so much time.

We'll make the dialog for you if you pay for the software and our time. Doing something in one dialog or two seems like a strange thing to decide whether to purchase a piece of software or not.

When you say "almost exactly how my office is setup", that suggests there are some differences. If you have no coding experience then it'd be better to explain exactly what you want first, before any code is written, else we'll post a script that won't work for you and you won't be able to change it yourself, meaning we have to. Those differences may also mean a different approach makes more sense, depending on what they are.

Understood. The difference was the drive. Instead of the "P" drive we were using a different letter...BUT let's leave it at "P" drive.

Purchasing the software I can do now. Can you please first give me a estimate or rate of "your time" to write the script?

Thanks.

A script that splits an entry is not a big coding endeavour, but IMHO still overkill. If you are willing to type a slash, you can use one dialog:

Go PATH=P:\20{dlgstring|Enter 5 digits}

2023-05-19 - 19.40.39 - Directory_Opus

The script would not cost anything (as long as we're just talking about something that prompts for a couple of numbers and inserts them into a path/command).

Although Lxp's suggestion may mean you don't need it. Depends how much padding/formatting you need on the numbers, e.g. if you don't want to type the extra zeros.

Ipx,
Thank you very much. This is very helpful too.

Leo,
When you get a chance please see if you can write a simple script.
Thank you.

1 Like

Here's a script that lets you type 5 digits without worrying about the backslash:

If the last number is less than 100, you don't need to pad it; the script will take care of that for you.

Examples:

  • Typing 12345 will take you to P:\2012\345
  • Typing 1234 will take you to P:\2012\034
  • Typing 123 will take you to P:\2012\003

(Typing less than 3 characters will do nothing, and it won't let you type more than 5.)

It doesn't currently verify that everything typed is a number, but that'd be easy to add if it's needed. (Nothing bad will happen on invalid inputs; it'll just try to go to a folder that doesn't exist and show an error message.)

You could also have a dialog with two separate string fields for the YY and MMM parts, but I figured that would require more typing, not less, so I went with this approach.

The script code is fairly simple, so if you want to change the text in the prompt, that's easy to do. ("MMM" is probably wrong here, since those aren't months, but I wasn't sure what to use instead.) The path near the bottom can also be adjusted if you need to.

DCF format, for easier adding to a toolbar:

Script code for reference (this is contained in the .dcf file above):

function OnClick(clickData)
{
	var dlg = clickData.func.dlg;
	dlg.title = 'Go to date';
	dlg.message = 'Enter YYMMM:';
	dlg.buttons = 'OK|Cancel';
	dlg.max = 5; // Max 5 characters
	if (dlg.Show() != 1)
		return;

	var s = dlg.input;
	if (s.length < 3) // Min 3 characters
		return;

	// Split YY from MMM.
	var y = s.substr(0,2);
	var n = s.substr(2);
	// Pad MMM to 3 digits.
	while(n.length < 3)
		n = '0' + n;

	// Path in format: P:\20YY\MMM
	// (Backslashes must be doubled due to JScript.)
	var p = 'P:\\20' + y + '\\' + n;

	var cmd = clickData.func.command;
	cmd.RunCommand('Go PATH="' + p + '"');
}
1 Like

Dark mode, I hope to see soon. :smiley: