highlight a video file that was last opened

Features wanted...
Post Reply
knightsofni
Posts: 11
Joined: 12 May 2016 22:02

highlight a video file that was last opened

Post by knightsofni »

Hi there,

Got the XYplorer premium a while ago, and it's absolutely the one I like most of all file explorers I've tried! And that's a lot!

There's one thing I am missing though (or I can't find how to do it).

The program highlights recently changed files and such, but I'd like to highlight files that were recently opened.

To name a specific example:
You have a folder called "Tv series xyz" with a list of episodes. You watch episode 15 one night and the next night you forgot what episode you watched last night. You need to open episode 16, but you don't know. You forgot you watched episode 15 last night. It's not highlighting this by default.

I've customized it to have changed files to have a different background color and such, but is it possible to do this for files that were OPENED recently? Ideally I'd like to use 3 colors, one color for 'last file opened in a specific folder' and 2 other colors for second last and third last file that was opened. Any way to do this?

:beer:

highend
Posts: 14589
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: highlight a video file that was last opened

Post by highend »

Welcome to the club.

With PFAs (portable file associations) and a bit of scripting (by assigning labels), yeah possible.
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 14589
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: highlight a video file that was last opened

Post by highend »

Ok, an example of how this could be done:

1. Make sure permanent variables are enabled:
Configuration | Refresh, Icons, History | Scripting | Remember permanent variables

2. Save the script (at the bottom) in the XY scripts folder and give it the name "LabelLastOpened.xys"
Copy the script 1:1, all lines are indented by at least 4 spaces!
To get to the scripts folder use Menu - Scripting - Go to Scripts Folder

3. Menu - Tools - List Management - Portable File Associations...
Add a new entry like:

Code: Select all

avi;mkv>::load "LabelLastOpened.xys";
Make sure you've used the same script name as in 2.
Edit the associations if necessary (e.g. avi;mkv;mp4;mpeg...)

4. Edit the color values in the script ($color1, $color2, $color3) if necessary

5. Edit the $limitToFolder variable if necessary. For example if the whole highlightning
should only happen to files in "D:\Movies" (and all of it's subfolders) use:
$limitToFolder = "D:\Movies";
If there shouldn't be any path limitation, leave the variable empty as it is.

6. It should work (not heavily tested...)

Code: Select all

    perm $P_LastOpened;
    // 1 = Red, 2 = Orange, 3 = Yellow, 4 = Green, 5 = Blue, 6 = Purple, 7 = Grey
    $color1 = 4;
    $color2 = 2;
    $color3 = 6;
    $limitToFolder = "";

    // Limit to a specific folder (+ subfolders of it)
    if ($limitToFolder && strpos(gpc(<pfaitem>, "path"), $limitToFolder) == -1) { end 1==1; }

    $curColor     = tagitems("label", , <pfaitem>);
    $P_LastOpened = ModifyList($P_LastOpened, <pfaitem>);
    while ($i++ < gettoken($P_LastOpened, "count", "|")) {
        $item = gettoken($P_LastOpened, $i, "|");
        $color = ($i == 1) ? $color1 : (($i == 2) ? $color2 : $color3);
        tagitems("label", $color, $item);
    }
    writepv;
    savesettings 64;
    open <pfaitem>, "w";

function ModifyList($list, $item) {
    if !($list) { return $item; }
    elseif ($item == gettoken($list, 1, "|")) { return $list; }
    elseif (gettoken($list, "count", "|") == 3) {
        tagitems("label", "", gettoken($list, 3, "|"));
        $list = $item . "|" . gettoken($list, 2, "|", , 1);
    } else { $list = $item . "|" . $list; }
    return $list;
}
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: highlight a video file that was last opened

Post by yusef88 »

Hi highend
if you don't mind I tested your script and found a bug
Attachments
lastopened.png
lastopened.png (33.13 KiB) Viewed 1356 times

highend
Posts: 14589
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: highlight a video file that was last opened

Post by highend »

Yeah, no problem :)

Easily fixed by changing

Code: Select all

open $item, "w";
to:

Code: Select all

open <pfaitem>, "w";
Edited the original script as well...

Btw, I'll probably add a bit more sophisticated version of this to my "Executor" script (http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=13510)

Features I'm thinking of:
- All labels are bound to <number> of items for each folder on their own
- Configurable amount of files to remember (per folder - up to 7 (max nr. of available labels))
- Restrict to multiple folders + define if they should be recursive or not
- Exclusions of folders
- Assignment of extensions per folder (e.g. avi|mkv for a video folder, mp3|flac for a music folder)
- Configurable if labels are stored so that they survive the current session or not
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: highlight a video file that was last opened

Post by yusef88 »

Thanks for fixing and this smart script

Post Reply