Advanced Filtering Command for Field/Columns/Metadata

Hi there.

The filter bar is great. It allows fast filtering with wildcards.
The Find-Tool-Utility also accept many many filtering options.

But what is with Filtering inside an Opus command/button.

Is there a way to filter by i.e. Location or Date Taken or other Metadata?

You can apply filters you've saved earlier within commands.

You can't currently build new filters on the fly using commands, though.

How can i save filters within commands?

I meant that if you define and save a filter, you can then use that filter in a command. Not that commands can save filters (since they can't generate filters, I'm not sure what they would save).

You can create filters via the Find panel (Advanced tab), or anywhere else that shows the filter UI. e.g. Preferences / File Operations / Filters.

I figured out:
Thanks for the directions.

Defining:
Preferences -> File Operations -> Filters
OR direct creation of an ".ofi" file with the filter definition in "/dopusdata/Filters"-Folder.

Applying:
i.e SELECT FILTER

Theoretically if i want to have filter on the fly i should than create the OFI-File and that's it.

Thanks again.

And now practically.

A Button "Filter on the Fly".
It go in the opus filter directory.
Create line by line a ofi/xml-file with the filtering options.
In this example "location match image or location match pic".
This can be adjusted and extended with other metadata fields.
Then apply the filter as argument for the select command.

All files with paths/location containing pic or image will be selected.

[code]<?xml version="1.0"?>

Filter on the Fly
#newcommand

@externalonly
@runmode:hide

set filter_dir_path="%appdata%\GPSoftware\Directory Opus\Filters"
cd %filter_dir_path%

echo ^<?xml version="1.0" encoding="UTF-8"?^> >filteronthefly.ofi
echo ^<filter desc="" name="filteronthefly"^> >>filteronthefly.ofi
echo ^<clause match="yes" type="path" wildcards="yes"^>image^</clause^> >>filteronthefly.ofi
echo ^<clause link="or" match="yes" type="path" wildcards="yes"^>pic^</clause^> >>filteronthefly.ofi
echo ^</filter^> >>filteronthefly.ofi

"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /acmd SELECT filteronthefly FILTER

[/code]

Now what i actually wanted to do is an "exclude path" and an include path" filtering for flat-view.
Therefore i need some more help.

How do i use filter with hide or show commands?

Ok. I find this solution by myself.

the last two line in the button batch should be

[quote]"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /acmd SELECT filteronthefly FILTER HIDEUNSEL
"C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe" /acmd SELECT INVERT[/quote]

Than all and olny the selected files will be shown, the unselected will be hidden..

What i actually wanted to do is an "exclude path" and an include path" filtering for flat-view.
And using the button above and making small changes, i created the "exclude path"-button.

<?xml version="1.0"?> <button backcol="none" display="label" textcol="none"> <label>Exclude path</label> <tip>Hide all files which are on this location</tip> <icon1>#newcommand</icon1> <function type="batch"> <instruction>@externalonly</instruction> <instruction>@runmode:hide</instruction> <instruction /> <instruction>&quot;C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe&quot; /acmd Clipboard COPYNAMES=path</instruction> <instruction /> <instruction>set filter_dir_path=&quot;%appdata%\GPSoftware\Directory Opus\Filters&quot; </instruction> <instruction>cd %filter_dir_path%</instruction> <instruction /> <instruction>del filteronthefly.ofi</instruction> <instruction /> <instruction>echo ^&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?^&gt; &gt;filteronthefly.ofi</instruction> <instruction>echo ^&lt;filter desc=&quot;&quot; name=&quot;filteronthefly&quot;^&gt; &gt;&gt;filteronthefly.ofi</instruction> <instruction>echo ^&lt;clause match=&quot;yes&quot; type=&quot;path&quot; wildcards=&quot;no&quot;^&gt;{clip}^&lt;/clause^&gt; &gt;&gt;filteronthefly.ofi </instruction> <instruction>echo ^&lt;/filter^&gt; &gt;&gt;filteronthefly.ofi</instruction> <instruction /> <instruction>@async</instruction> <instruction>&quot;C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe&quot; /acmd SELECT filteronthefly FILTER HIDESEL</instruction> </function> </button>

So when man has flatview and some folders are not important and better be hidden, simply select at least one file and than click exclude path.
All other items from this location disappear.
Tested with FlatView mixednofolders.

The button do what i described, but i encounter one small problem with the creation of filter on the fly.
Each time when the filter is created, the hidding button apply the "old version" of the filter content.

I.e.:
i select "C:\path1\file1.txt" and click "exclude path" -> only this file disappears.
i select "C:\path2\file2.txt" and click "exclude path" -> the file "C:\path2\file2.txt" disappears and all files inside "C:\path1"

There is a "delay" or "asynchronism", so to speak.
Opus load the filter version sooner than i need.

How can i force Opus to reload the filter definition?
Are there modifiers that could be helpful?

What you're doing there is unsupported. There's no guarantee that Opus will notice direct changes to the XML config files at all except when it starts up. Sometimes those files are cached in memory.

That said, it might work without the @async there (not sure what that is doing there), or maybe with some kind of delay between writing the file and running the select command, or by writing the file in a different way (maybe the DOS echo command isn't flushing the changes to disk until the batch file completes or something).

the @async was just a try. shouldn't be there.

In order to check the delay problem, I slitted the button in two buttons.
One for filter creation, and one for execution.
Problem was not solved.
I found out the problem is in the Clipboard COPYNAMES=path
The old clipboard content has been delivered. Not the actual one. There is a queue.

How can get the location path otherwise without clipboard?
This was a workaround for me. I don't like overwriting or adding content there with commands.

The {filepath} contains a Backslash, the filename and the extension.
I don't need them, but there are no modifiers, to get the location path only. Or?

I tried splitting filepath to path and file in batch cmd, but is was to ugly and was not working.
Not so ugly was powershell splitt-path command. But this mean dependency. It may works on old system, it may not.

I want to use internal opus commands only.
Please tell me how?

[quote="aDopusUser"]The {filepath} contains a Backslash, the filename and the extension.
I don't need them, but there are no modifiers, to get the location path only. Or?[/quote]

{filepath|..|noterm} will give you the parent of {filepath}, without the backslash on the end.

it works like a charm, thanks

I was not happy with the dos-batch escaping of filenames. All not latin character an ampersand make some trouble.
Therefore i try to run a php-script for processing selected files, an creating filter on the fly.

"C:\php\php.exe" "D:\dopus_scripts\exclude_path.php" {allfilepath|..|noterm}

The script get the filepaths but the modifiers "|..|term" are ignored.
Why is that?

I don't think those modifiers are supported with {allfilepath} or the other {all*} codes that output multiple filenames.

But since you're passing the filenames to php it should be easy to process them within the script. (You'd need to do that anyway to remove duplicate parent folders.)

By the way, you might want to use {allfilepath|filem|utf8} to pass the script the name of a temp-file containing the list of filenames, instead of passing the filenames directly, so that you don't run into command-line length limits. (I'm assuming utf8 is best for php, but there are other options for the encoding if needed.)

I was following the manual in section:
Reference > Command Reference > External control codes > Codes for passing filenames:

The hint about {allfilepath|filem|utf8} is a good one.
This was my other thought.
I will try that.