Clean Recent Menu

Discuss and share scripts and script files...
LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Clean Recent Menu

Post by LittleBiG »

Recent locations only with existing paths. Write ::snippet into the address bar. Copy the content below into the window which appears, then click ok. You will have a new Recent button.

Code: Select all

Snip: CTB 1
  XYplorer 13.90.0104, 2014.04.10. 22:53:55
Action
  NewUserButton
Name
  Clean Recent
Icon
  :mru
ScriptL
  "_Initialize"
    $limit = 32;
    $count = 0;
    $sfile = """CLEAN RECENT""" . <crlf> . """-""" . <crlf>;
    foreach($recpath, get("list_recentlocations"), <crlf>,, "") {
      if ($count < $limit) {
        if (exists($recpath) > 0) {
        $sfile = $sfile . '"' . $recpath . "|*" . '"' . " goto " . '"' . $recpath . '"' . "<crlf>";
        $count++;
      }
    }
    }
    writefile("<xyscripts>\CleanRecent_Menu.xys", $sfile, "o");
  "Show Menu"
    load "CleanRecent_Menu.xys";
ScriptR
 
FireClick
  1
Last edited by LittleBiG on 11 Apr 2014 15:39, edited 1 time in total.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Thank you LittleBig,
cannot get it to work. No error message, but nothing happens. After running it everything is just like before. :eh:
I am on 13.90.0102

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

This creates a new user button at the end of the toolbar, with the same icon as the Recent (blue circle). Did you click on that? You should see the menu name grayed out "CLEAN RECENT" at least.

This script doesn't remove the unaccessible paths from the original recent locations (I can't do that), but shows only the "live" folders of the recent locations.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Got it. (It had dropped off the screen)
Doesn't even take a restart to get rid of invalid paths. Great. 8)
And loads all by itself, no need to tweak the startup parameters.

The only downside:
It's cluttered in a different way: Not with broken links, but it doesn't group/sort like the real thing. After browsing a bunch of user drives, the list looks like a randomly shuffled alphabet. :?

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

This is the Recent locations. It has never been grouped or sorted alphabetically. It is the hotlist.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

You're right. Sorry for the confusion.
I really like the Hotlist. If only it wouldn't keep those tons of obsolete entries. My most visited place in XY is the CLEAR-button of that list. Closely followed by some other lists. Wish I could automate that somehow.

Experimented with catalog sets and favorites, but that's too much hassle in my portable environments. Seems like I have to live with it.

Thanks again for this alternative, LittleBig. Will try both lists (Hotlist and yours) for a while and see what suits me better.

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

Let me give you a last alternative. The only downside of the Hotlist is that it shows only tree leafs. With this solution, you can easily modify the number of items in the recent locations, plus sort and group it if you want.

Create a script file (for example CleanRecent.xys) with this content:

Code: Select all

"_loadrecent"
  $count = 0;
  $sfile = readfile(self("file"));
  $limitlabel = "Actual "."Limit: ";
  $limit = substr($sfile,strpos($sfile,$limitlabel)+strlen($limitlabel),strpos(substr($sfile,strpos($sfile,$limitlabel)),"|")-strlen($limitlabel));
  // the script remains intact before the separator
  $sfile = SubStr($sfile, 0, StrPos($sfile,'//separate', -1) + 10) . "<crlf>";
  $ownrecent = "";
  foreach($recpath, get("list_recentlocations"), <crlf>,, "") {
    if ($count < $limit) {
      if (substr($recpath,0,2) == "\\") {
       $ownrecent = $ownrecent . '"' . $recpath . "|*" . '"' . " goto " . '"' . $recpath . '"' . "<crlf>";
        $count++;
     }
     else
     {
       if (exists($recpath) > 0) {
          $ownrecent = $ownrecent . '"' . $recpath . "|*" . '"' . " goto " . '"' . $recpath . '"' . "<crlf>";
          $count++;
      }
      }
    }
   else {
     break;
   }
  }
  $ownrecent = formatlist($ownrecent,"e","<crlf>");
  if (strpos($sfile,"Sorted and Grouped: " . "Yes") != -1) {
    $ownrecent = formatlist($ownrecent,"s","<crlf>");
    $grouped = "";
    $lastletter = "";
    foreach($path, $ownrecent, <crlf>,, "") {
      if ($lastletter == "") {
       $lastletter = substr($path,1,1);
       }
     else
     {
       if ($lastletter != substr($path,1,1)) {
          $grouped = $grouped . "-" . <crlf>;
        $lastletter = substr($path,1,1);
       }
     }
     $grouped = $grouped . $path . <crlf>;
   }
   $ownrecent = $grouped;
  }
  writefile(self("file"), $sfile.$ownrecent, "o");
"CLEAN RECENT"
"Actual Limit: 24|:rename"
  $limitlabel = "Actual "."Limit: ";
  $new_limit = input("New limit:")*1;
  $sfile = readfile(self("file"));
  $sfile = RegExReplace($sfile, $limitlabel."\d+", $limitlabel.$new_limit, 1);
  writefile(self("file"), $sfile, "o");
"Sorted and Grouped: No|:sort"
  $sfile=readfile(self("file"));
  if (strpos($sfile, "Sorted and Grouped: " . "Yes") == -1) {
    $sfile=replace($sfile, "Sorted and Grouped: " . "No", "Sorted and Grouped: " . "Yes", , , 1);
  }
  else {
    $sfile=replace($sfile, "Sorted and Grouped: " . "Yes", "Sorted and Grouped: " . "No", , , 1);
  }
  writefile(self("file"), $sfile, "o");
"-"
//separate
Create a new user button and write this into the "On left click" field:

Code: Select all

load "CleanRecent", "_loadrecent"; load "CleanRecent"
You can name the button and add icon as you want. (Tip: try to click on the Actual Limit and Sorted menu items.)

EDIT: Typos corrected.
Last edited by LittleBiG on 14 Apr 2014 11:56, edited 4 times in total.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Thanks for sticking with it.
This is what I get:
Error.png
Error.png (12.41 KiB) Viewed 5534 times

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

It looks like some problem with the copy-paste. I give you rather the file. Copy it into the Script folder then create the user button as I wrote above.

EDIT: Corrected.
Attachments
CleanRecent.xys
(2.2 KiB) Downloaded 230 times
Last edited by LittleBiG on 14 Apr 2014 11:57, edited 4 times in total.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

This is neither little nor big, but huge, enormous, gigantic, herculean. This rocks. :biggrin:
Especially the limit and the toggle between group and chronological.

Now, without meaning to over-extend your helpfulness, could you include that part from the other script that clears out invalid entries? Cannot do it myself, feel stupid enough for my failed copy&paste. To my defense, I relied on "Select All" before I went ahead and pressed Ctrl C and Ctrl V.

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

You can find it here at the original place. There were typos in that, which I corrected. http://www.xyplorer.com/xyfc/viewtopic. ... 26#p102926

Stef123

Re: Clean Recent Menu

Post by Stef123 »

I should me more elaborate.
What I refer to are the invalid entries in the list of the ClearRecent TB-button. Not the mini-tree.

In your first take on the button-dropdown (the one I inserted via the address bar), invalid entries were filtered out. Now with the last version (which contains all the killer features) they are kept in the list again, which sort of loops me back to my original wish that got me started on this in the first place.

No hurry, though. I need to catch up on other stuff, will be busy over the weekend.

LittleBiG
Posts: 1846
Joined: 08 Apr 2011 12:57
Location: Win10x64

Re: Clean Recent Menu

Post by LittleBiG »

OK, done. 2 typos prevented the correct way of working. Fixed.

Stef123

Re: Clean Recent Menu

Post by Stef123 »

Wonderful. :appl:
My only wish remaining concerns the tiny font size, to make this thing perfect. On HD monitors I operate XY with a magnifier (no kidding). I cannot crank up the tooltip setting in Windows, and I know there is no official way to do this in XY. But since you surpassed my wildest hopes with this script - any chance to tweak the font size?

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

Re: Clean Recent Menu

Post by klownboy »

LittleBiG, very impressive and quite handy! :appl: I especially like your long replace line $sfile = replace($sfile,substr($sfile,strpos............................) I gave up trying to follow it through. :D
It wasn't working completely for me initially (i.e., didn't update to my Recent Locations - it kept yours) since to test it, I had quickly assigned it to a right click of an existing CTB which already had a left click assignment just to save me from making up a new button. Everything worked fine when I switched to a left click assignment. Good job and thanks.
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply