Tip: Safely filter items which may contain [ or # or ;

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
FluxTorpedoe
Posts: 906
Joined: 05 Oct 2011 13:15

Tip: Safely filter items which may contain [ or # or ;

Post by FluxTorpedoe »

Hi'
Since it took me a looong while to figure out the existing simple solution, I thought I might as well share it.

In a script, if you want to filter items (e.g. on their reported attributes), it may not work when processing files or folders containing "[" or "#" or ";".
- A solution involves using the flag: "filter item, 1", but it only takes care of the "["
- Another solution is to escape those characters with square brackets, i.e. "[[]", which may become troublesome with exact matches...

:arrow: A simple solution (considering you need exact matches too) is to:
- fully "quote" every item (e.g. in your foreach or your regexmatches),
- and separate them with a "|",
- without escaping any character, and
- without using the ", 1" flag.

Note that your item(s)/variable(s) must really be quoted, so for it to work, the resolved command should look like e.g.
filter "a#c.txt"|"a;c.txt";
filter """a#c.txt""";

Hoping this may help someone filtering by custom labels or specific properties... 8)
Flux

Post Reply