Tip: Simple file-based favorites

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
admin
Site Admin
Posts: 64894
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Tip: Simple file-based favorites

Post by admin »

FYI, with the latest version v9.60.0013 you can turn simple text files (that just contain a number of paths) into clickable popup menus when you load them as script files.

For example, create a file goto.xys and paste this:

Code: Select all

Desktop
C:\WINDOWS\system.ini
C:\WINDOWS\system32
Then select the file and click menu Scripting | Load selected Script File.

Hey, in v9.60.0014 also this will work: 8)

Code: Select all

Desktop
%tmp%
<xydata>
C:\WINDOWS\system.ini
C:\WINDOWS\system32

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

...then I just have to ::load favs or assign an alias for it.
Later I'll add a "edit this script" function for this.
Best of all: under certain circumstances, the little EASIER to handle custom menu will pop under the mouse pointer.
Now I have a fleXYble way to handle my session-based favorites without having to save XY config over and over again. Wow.
The awesomeness of this is fantabulous...
Thanks again, Don!!! :mrgreen:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

Is there a way to easily import (options:) pane 1, pane 2 or both panes' tabs to such "favs.xys", people...?
-if so, now we have another kind of Session Manager, too!!!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

Stefan
Posts: 1360
Joined: 18 Nov 2008 21:47
Location: Europe

Re: Tip: Simple file-based favorites

Post by Stefan »

SkyFrontier wrote:Is there a way to easily import (options:) pane 1, pane 2 or both panes' tabs to such "favs.xys", people...?

Code: Select all

//collect paths from all tabs in current pane:
$TabCount = tab(,"c"); //how many tabs are open?
   //$Pane = getinfo("Pane"); //which pane is active?

   $Loop = 1;
   $Tabs = ""; 
   while ($Loop<=$TabCount)  //for each tab do
   {
     $Tabs = $Tabs . tab("get", "path", $Loop) . "<crlf>"; 
     incr $Loop;
   }
   writefile("C:\Temp\fav.xys", $Tabs);


//add CTB:
//http://www.xyplorer.com/xyfc/viewtopic.php?p=51737#p51737

 $CTB = <<<Heredoc
Snip: CTB 1
  XYplorer 
Action
  NewUserButton
Name
  My Temp Favorites
Icon
  :favs
ScriptL
  Load "C:\Temp\fav";

ScriptR
 
FireClick
  1
Heredoc;
  snippet  $CTB;

admin
Site Admin
Posts: 64894
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Tip: Simple file-based favorites

Post by admin »

Wow! Funny idea to first wrap the snippet in a script and then the script in a snippet. :D

But please, don't do the jurassic incr $Loop; -- do $Loop++; instead!

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

Added the following code to get the thing running under CTRL+F (free as default);
-it has the tab("get", "path", $Loop) . "\<crlf>"; parameter so each path will end with a "\", which will pop a message asking to create a currently non-available location (ideal solution for us, portable soldiers!) - only possible thanks to the freak paths handling and the create folders for non-existent locations trick.
--but when you cancel creating such folder XY pops an "scripting error" message... Can this be avoided?
-tried to write a little "Set Favorites from Tabs/Inactive Pane", but couldn't do it. Open for suggestions ("pane switcher" dialog?, whatever... - despite this means another dialog to deal with).
-am I missing something or I really can't assign a keyboard shortcut to a script attached under a CTB? That way I could get a cleaner UDC, currently filled with little scripts just to get the ks function...

Code: Select all

"Menu FAVORITES|:favs"
   load "<xyscripts>\favs.xys";
"Set Favorites from Tabs/Active Pane|:conf"
//collect paths from all tabs in current pane:
   $TabCount = tab(,"c"); //how many tabs are open?
   //$Pane = getinfo("Pane"); //which pane is active?

   $Loop = 1;
   $Tabs = "";
   while ($Loop<=$TabCount)  //for each tab do
   {
     $Tabs = $Tabs . tab("get", "path", $Loop) . "\<crlf>";
     incr $Loop;
   }
   writefile("<xyscripts>\favs.xys", $Tabs);
   sel;
   status "Tabs stored as (Favorites) favs.xys!";
"Edit/Check Favorites File|:udc"
   open "<xyscripts>\favs.xys";
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

Is there an easy way to get Hotlist as a source for building this list, too?
It's Hotlist's main goal to keep track of the most accessed folders, so it's a reliable source for such a task.
It seems to be stored under "actions.dat", but it should be an easier way to export it via List Management > select all and copy (currently not possible even for the simple History itself).
Side note: if such functionality can be implemented, please make the outputs ending with a "\", so the "create if non-existent" trick can be supported for this.
----
The below script is a version that offers access to a PermaFavorites list, so it can list "Hotlist" content if/when supported. That way "favs" can be a session manager, and "favsp", a reliable file-base favorites.
Layout was made having usability in mind, so the most common items are placed on top positions.

Code: Select all

"PERMAfavorites|:favfiles"
   load "<xyscripts>\favsp.xys";
"Menu FAVORITES|:favs"
   load "<xyscripts>\favs.xys";
"Set Favorites from Tabs/Active Pane|:conf"
//collect paths from all tabs in current pane:
   $TabCount = tab(,"c"); //how many tabs are open?
   //$Pane = getinfo("Pane"); //which pane is active?

   $Loop = 1;
   $Tabs = "";
   while ($Loop<=$TabCount)  //for each tab do
   {
     $Tabs = $Tabs . tab("get", "path", $Loop) . "\<crlf>";
     incr $Loop;
   }
   writefile("<xyscripts>\favs.xys", $Tabs);
   sel;
   status "Tabs stored as (Favorites) favs.xys!";
"Edit/Check Favorites File|:udc"
   open "<xyscripts>\favs.xys";
"Set PERMAFavorites from Tabs/Active Pane|:conf"
//collect paths from all tabs in current pane:
   $TabCount = tab(,"c"); //how many tabs are open?
   //$Pane = getinfo("Pane"); //which pane is active?

   $Loop = 1;
   $Tabs = "";
   while ($Loop<=$TabCount)  //for each tab do
   {
     $Tabs = $Tabs . tab("get", "path", $Loop) . "\<crlf>";
     incr $Loop;
   }
   writefile("<xyscripts>\favsp.xys", $Tabs);
   sel;
   status "Tabs stored as (Favorites) favs.xys!";
"Edit/Check PERMAFavorites File|:udc"
   open "<xyscripts>\favsp.xys";
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

admin
Site Admin
Posts: 64894
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Tip: Simple file-based favorites

Post by admin »

SkyFrontier wrote:Added the following code to get the thing running under CTRL+F (free as default);
-it has the tab("get", "path", $Loop) . "\<crlf>"; parameter so each path will end with a "\", which will pop a message asking to create a currently non-available location (ideal solution for us, portable soldiers!) - only possible thanks to the freak paths handling and the create folders for non-existent locations trick.
--but when you cancel creating such folder XY pops an "scripting error" message... Can this be avoided?
Currently not. This might be important information for the user running the script so I think it should stay as it is.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

SkyFrontier wrote:Currently not. This ("scripting error" message) might be important information
Agree on this but still see as a valid request since disabling such dialogs individually and temporally (like the "AllowRecursion" trick) makes sense for known scripts - the ones we tested over time and see that the only (minor) issue is this.
----
Regarding the Hotlist/Recent Locations items export, what about adding a "Copy/Export locations" button on the bottom of them?
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Tip: Simple file-based favorites

Post by TheQwerty »

SkyFrontier wrote:Agree on this but still see as a valid request since disabling such dialogs individually and temporally (like the "AllowRecursion" trick) makes sense for known scripts - the ones we tested over time and see that the only (minor) issue is this.
In that case the script writer can work around it by checking the existence with Exists and then prompting (Confirm) the user to create (New) or ignore.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

TheQwerty wrote:
SkyFrontier wrote:Agree on this but still see as a valid request since disabling such dialogs individually and temporally (like the "AllowRecursion" trick) makes sense for known scripts - the ones we tested over time and see that the only (minor) issue is this.
In that case the script writer can work around it by checking the existence with Exists and then prompting (Confirm) the user to create (New) or ignore.
The skilled script writers, you mean? :wink:
Thanks for the tip, TheQwerty - hope I manage to achieve that effect (there's a good bunch of my own scripts I'd need to revise against this, but - not for now while I don't know how...).
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Tip: Simple file-based favorites

Post by TheQwerty »

SkyFrontier wrote:The skilled script writers, you mean? :wink:
Thanks for the tip, TheQwerty - hope I manage to achieve that effect (there's a good bunch of my own scripts I'd need to revise against this, but - not for now while I don't know how...).
I actually have to take that back anyhow... I wasn't paying attention but with the implied goto, and the format of the above script there really isn't a way for you to add such a check easily.

You could only write out the locations which exist to your favs*.xys files, but that wouldn't necessarily be portable.
or
You could add a wrapper around the whole thing that would read the files and perform a check as mentioned and then Load the modified contents of the favs*.xys (it shouldn't need to modify the file's written data).

However, it might be easier to get one of the existing tab manager scripts working with a simple flat favorites file.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: Tip: Simple file-based favorites

Post by SkyFrontier »

Code: Select all

v9.60.0014 - 2010-10-19 13:02
    + Scripting: The multi-script goto-shorthand now also supports
      environment and native variables, name searches, and visual
      filters. For example:
        Desktop
        %tmp%
        <xydata>
        C:\WINDOWS\system.ini
        C:\WINDOWS\system32
        C:\WINDOWS\system32?a*
        C:\WINDOWS\system32?:a* or b*
        C:\WINDOWS\system32?:a* | b*
        C:\WINDOWS\system32?tag:blue
        C:\WINDOWS\system32|a*
The thing is powerful - I used the "goto "*?tag:*"" pattern in it and IT WORKED!!! :D
Don, do you plan to offer custom icons and label/caption support for this one, too? Or will this necessarily conflict with Visual Filter?
C:\Documents and Settings\Admin\Dados de aplicativos\Local Stuff\Administrative\System Wide\Microsoft\SystemCertificates\My\Certificates\|*VISUAL FILTER* (whatever value)|:props (Icon)|Admin SysCerts (caption to be displayed instead of this longish path)
----
TheQwerty:
However, it might be easier to get one of the existing tab manager scripts working with a simple flat favorites file.
Would you mind in building a sample code on this actually working?
I just can't see how this could be done the way you describe (sorry...).
Remember: the aim is to avoid the (now called) XYplorer Scripting message when clicking "Cancel" at the "not available: create?" dialog, invoked by trying to go to a currently non-existent location from the new file-based favs.
----
Generic tip:
I've workaround'ed the list building limitation using Yankee Clipper: it was a mere question of "click Hotlist item > press CTRL+C > loop" (to my surprise the items are kept focused on address bar, so it was a piece of cake!!!). The list was built inversely (top to bottom, 1st items being the last ones), but that is a minor problem for Cream/VIM. It's strange having to get away from home... :wink:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Tip: Simple file-based favorites

Post by TheQwerty »

SkyFrontier wrote:
However, it might be easier to get one of the existing tab manager scripts working with a simple flat favorites file.
Would you mind in building a sample code on this actually working?
I just can't see how this could be done the way you describe (sorry...).
Remember: the aim is to avoid the (now called) XYplorer Scripting message when clicking "Cancel" at the "not available: create?" dialog, invoked by trying to go to a currently non-existent location from the new file-based favs.
My suggestion avoids seeing XY's "create?" dialog entirely.

But no, I don't have the time to build something on top of someone's tab manager.

admin
Site Admin
Posts: 64894
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Tip: Simple file-based favorites

Post by admin »

SkyFrontier wrote:

Code: Select all

v9.60.0014 - 2010-10-19 13:02
    + Scripting: The multi-script goto-shorthand now also supports
      environment and native variables, name searches, and visual
      filters. For example:
        Desktop
        %tmp%
        <xydata>
        C:\WINDOWS\system.ini
        C:\WINDOWS\system32
        C:\WINDOWS\system32?a*
        C:\WINDOWS\system32?:a* or b*
        C:\WINDOWS\system32?:a* | b*
        C:\WINDOWS\system32?tag:blue
        C:\WINDOWS\system32|a*
The thing is powerful - I used the "goto "*?tag:*"" pattern in it and IT WORKED!!! :D
Don, do you plan to offer custom icons and label/caption support for this one, too?
This is a shorthand version for those who are happy with the vanilla choices. If you want more use the longhand:

Code: Select all

"Caption|Icon" goto "C:\Windows";
:)

Post Reply