Better file / folder selector

Discuss and share scripts and script files...
bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Better file / folder selector

Post by bdeshi »

Insider knowledge :wink: , straight from the script:

Code: Select all

<start number>|<every nth number> -> 1|3 (first item and every 3rd afterwards...)
That's the syntax of every nth item
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

Took me a moment to figure out how to restrict it to extensions only (DOS expression). An additional drop-down option "Extensions only" would spare the repeated typing of "*." but it's no big deal.
What did you try to select exactly (real world example where such a dropdown would be necessary)? I'm just working on an easier way to preselect things so this would help me to get a better understanding.
What does Match: Random do?
You enter a number. E.g. 10

20 items are in the current folder. 10 random ones will be selected afterwards. Nice if you want to randomize e.g. mp3 files.
And how do I get "every nth item" to work?
30 items in the current folder and you want to select the first and then every 2nd after it. Use
1:2 to do that.

... Do not... Encountered a bug...

Code: Select all

        $startValue = gettoken($fn_Pattern, 1, "|");
        $stepValue  = gettoken($fn_Pattern, 2, "|");

        if ($startValue < 1 || $stepValue < 1 || strpos($fn_Pattern, ":") == -1) {
            status "You did not enter a valid pattern! Required: <start number>:<every nth number>", "8B4513", "stop"; // saddlebrown
            end 1=1;
        }
$startValue & $stepValue are using the "|" separator but the if checks for ":". It will always fail^^

Edit: Fixed for the next version...

But this will take a while, I'm currently working on branch view support.

This will (if it's fast enough) even more powerful because you would be able to make a selection with
Property -> #mp3.artist -> Kelly::James for your whole .mp3 collection...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Stef123

Re: Better file / folder selector

Post by Stef123 »

Thanks. Great idea to allow users to pick the start position of "every nth item".
highend wrote:I'm currently working on branch view support.
Terrific. That will shift gears and reach new worfklow speeds. Here's a real-world branch view scenario: My Photoshop presets folder harbors more than 1,000 files in 44 subfolders. I want to carry along all my custom brushes "abr" but not any *fabric.asl (styles) or *fabric.pat (patterns) etc.

I also need my color swatches (aso), actions (atn), Hue+Saturation (ahu) but NO OTHER preset-extensions that may have aso, atn, ahu etc in the middle of their names. I won't be checking up on this when I rich-copy to the destination preset folder, my default is an automatic overwrite. I know what I am doing, provided I don't have any blind passengers in the copy-bag to start with.

An extension-only match would make the pattern easier "abr::aso::atn::ahu"! without having to worry about dots and asterisks. Even easier, of course, were checkboxes in the extension drop-down. But I don't want to over-extend your helpfulness.

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

This should already be possible.

Match: Ends with
Extension: <all>
[x] Incl. ext
Pattern: jpg::ini

This will select only those files that really end on "jpg" or "ini" regardless if jpg / ini is part anywhere in the filename as well...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Stef123

Re: Better file / folder selector

Post by Stef123 »

Ha - you're right. Didn't think of this solution. GREAT. Thanks :D

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

The same would have been possible with:

Match: Regular Expression
Extension: <all>
[x] Incl. ext
Pattern: jpg$::ini$

or:
Pattern: (jpg|ini)$

Now back on branch view support...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

I have a test version that works with an activated branch view... If anyone wants to test it, write me a pm with an e-mail address...

Don't use it with more than a thousand files atm, it takes time to run all of them through e.g. a property search...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

Ok, v1.0 is out...

Branch view support...
Many small improvements & (nasty) bug fixing. I hope I got all.

If you're in branch view, BFS will use all files / folders in it, if not, business as usual^^
Be careful, processing thousands of files takes time!

Question:
Should the script allow the user to switch to / from branch view with a button?
Imho it should use: :flatfiles in that case...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

klownboy
Posts: 4052
Joined: 28 Feb 2012 19:27

Re: Better file / folder selector

Post by klownboy »

Thanks highend, v1.0 is looking good. I haven't used branch view much so I'll stay away from that question.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

bdeshi
Posts: 4249
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612 / Dhaka
Contact:

Re: Better file / folder selector

Post by bdeshi »

Perhaps a warning/confirmation before filtering if flatview is going to list more than a handful of files (you never know what lurks in a subfolder... )
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

I haven't used branch view much so I'll stay away from that question
I don't use it very often, too. But with BFS it can be incredible useful!

Image that you can go to the rootfolder of a mp3 collection and select all files (or make a paperfolder of them)
with bitrate=192 && genre=rock && artist=queen. You can't do the same from the gui and remembering the
syntax of quick find... em...

I'll have to rewrite most of the script. I have a better idea to improve the speed for large file selections...
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Stef123

Re: Better file / folder selector

Post by Stef123 »

Small bug that I never mentioned, but now as I am doing major renames with file suffixes it wish I had reported it earlier: Match "Ends with" works the same as "Begin With", it won't find the suffixes but gets me the prefixes instead.

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

Yeah, true. "Begins" with and "ends with" share the same code block xD

Atm I'm working on changing all major loops into regex matches/replaces (which is rather tricky for some of them ;( ) to speed up execution times for large selections (e.g. in branch views)). This will take a while and I don't know if it's worth the effort because that'll lead to interesting side effects. Probably rare cases (it's mainly about directories with dots in them that won't be selected / not selected correctly). At someday I'll do an interim release and see what people tell me about it.

In the meantime, find this block of code:

Code: Select all

        // Use a temporary pattern so that the original is restored on the next form invocation
        // For "Begin with" & "End with"
        if (strpos($P_BFS_MatchMethod, "match_begin_with") != -1 || strpos($P_BFS_MatchMethod, "match_end_with") != -1) {
            $tmpPattern = "";
            foreach($pattern, $P_BFS_Pattern, "::") {
                $tmpPattern = $tmpPattern . "^$pattern.*" . "::";
            }
            $tmpPattern = trim($tmpPattern, "::", "R");
        }
and replace it with:

Code: Select all

        // Use a temporary pattern so that the original is restored on the next form invocation
        // Begin with
        if (strpos($P_BFS_MatchMethod, "match_begin_with") != -1) {
            $tmpPattern = "";
            foreach($pattern, $P_BFS_Pattern, "::") {
                $tmpPattern = $tmpPattern . "^$pattern.*" . "::";
            }
            $tmpPattern = trim($tmpPattern, "::", "R");
        // End with
        } elseif (strpos($P_BFS_MatchMethod, "match_end_with") != -1) {
            $tmpPattern = "";
            foreach($pattern, $P_BFS_Pattern, "::") {
                $tmpPattern = $tmpPattern . ".*?$pattern$" . "::";
            }
            $tmpPattern = trim($tmpPattern, "::", "R");
        }
This should work for the moment :)
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Stef123

Re: Better file / folder selector

Post by Stef123 »

That did the trick. Now it works as expected. There are some more niggles, but these don't bother me atm because other scripts take care of those instances.

Thanks for the quick fix.
Stef

highend
Posts: 13033
Joined: 06 Feb 2011 00:33

Re: Better file / folder selector

Post by highend »

There are some more niggles
Which ones exactly? :)
One of my scripts helped you out? Please donate via Paypal or paypal_donate (at) stdmail (dot) de

Post Reply