[solved] goto last file labelled green

Discuss and share scripts and script files...
lian00
Posts: 429
Joined: 09 Jul 2014 17:12

[solved] goto last file labelled green

Post by lian00 »

Hello,
I made some searches and the only things I managed to do is to show all green labelled files from a particular directory and select the last one. But I want to "go" to the last green labelled file in a directory. Il someone can help me...
Last edited by lian00 on 05 Dec 2015 14:52, edited 1 time in total.
Windows 10 64 bits

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

Re: goto last file labelled green

Post by highend »

goto "your file name"; scrolls a file into view (if that's what you mean).
One of my scripts helped you out? Please donate via Paypal

lian00
Posts: 429
Joined: 09 Jul 2014 17:12

Re: goto last file labelled green

Post by lian00 »

Well, I don't "know" the name of the file. I'm looking at a directory to delete files I don't want to keep. I label in green the last file I have looked at and want to jump to it directly when I have time to go on with this work. So I have some green labelled files in a lot of files and need to jump directly to the last one.
Windows 10 64 bits

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

Re: goto last file labelled green

Post by highend »

I'm not sure what you're trying to do exactly...

Jumping to the LAST green labeled file (regardless where it is)?

Code: Select all

    savesettings 64;
    $tags  = readfile("<xydata>\tag.dat");
    $match = regexmatches($tags, "^.*?\|4", "<crlf>");
    $file  = regexreplace(gettoken($match, 1, "<crlf>"), "\|4$");
    tag 0, $file;
    savesettings 64;
    goto $file;
One of my scripts helped you out? Please donate via Paypal

lian00
Posts: 429
Joined: 09 Jul 2014 17:12

Re: goto last file labelled green

Post by lian00 »

I will try your script. There is one thing I know: I know the directory - it's my work directory.
Windows 10 64 bits

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: goto last file labelled green

Post by bdeshi »

highend, tag.dat lists files alphabetically by path.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: goto last file labelled green

Post by highend »

@SammaySarkar

Ups, you're right :) Scratch that idea!

For a better working "Bookmark system" you'd need e.g. a toolbar button and do the labeling with that.

It could set the green label AND store the current date as a tag and that would let you do what you want...
One of my scripts helped you out? Please donate via Paypal

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

Re: goto last file labelled green

Post by highend »

A better one:

You need two buttons / user defined commands with shortcuts / whatever

The first script "bookmarks" a file (by setting the label + tag)

The second one goes to the last set bookmark (and deletes that file from the tag.dat database to "forget about it")

Code: Select all

    // Set bookmark
    tagitems("label", 4, "<curitem>");
    tagitems("tags", "<date yyyymmddhhmmss>", "<curitem>");
    savesettings 64;

Code: Select all

    // Go to bookmark
    $tags  = readfile("<xydata>\tag.dat");
    $bookmarked = replace(regexmatches($tags, "\|4\|\d{14}", "<crlf>"), "|4|");
    $latest = gettoken(formatlist($bookmarked, "r", "<crlf>"), 1, "<crlf>");
    $file  = regexreplace(regexmatches($tags, "^.*?\|4\|$latest", "<crlf>"), "\|.*$");
    tag "$latest", $file, 1, 2;
    tag 0, $file;
    savesettings 64;
    goto $file;
One of my scripts helped you out? Please donate via Paypal

lian00
Posts: 429
Joined: 09 Jul 2014 17:12

Re: goto last file labelled green

Post by lian00 »

Well,
I wrote this:

Code: Select all

goto "E:\telechargement\photos-xz\2014?lbl:green";
	sel -1, , 1; //select the last item in the list
	$selections = get("selecteditemsnames", "|");  
	goto "E:\telechargement\photos-xz\2014";
	selectitems $selections;
So I select the last green item in the directory. It will be the job but it could be nice to "show" the file in the list (it's selected for the moment but I cannot see it as there are a lot of files). I need to "jump" to the file.
Windows 10 64 bits

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

Re: goto last file labelled green

Post by highend »

You mean something like this?

Code: Select all

    goto "E:\telechargement\photos-xz\2014?lbl:green";
    goto gettoken("<allitems |>", -1, "|");
One of my scripts helped you out? Please donate via Paypal

lian00
Posts: 429
Joined: 09 Jul 2014 17:12

Re: goto last file labelled green

Post by lian00 »

gettocken gives me the name of the file. But I need to select it - and eventually jump to it.

In XYPlorer when you get the name of a file and start to type it, you jump to the file. Is there a way to make this with a script ?
Windows 10 64 bits

lian00
Posts: 429
Joined: 09 Jul 2014 17:12

Re: [solved] goto last file labelled green

Post by lian00 »

OK, my script works as intended. I suppose it's very bad code but it works :-) as needed for me.
Windows 10 64 bits

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: [solved] goto last file labelled green

Post by bdeshi »

lian00 wrote:gettocken gives me the name of the file. But I need to select it - and eventually jump to it.

In XYPlorer when you get the name of a file and start to type it, you jump to the file. Is there a way to make this with a script ?

Code: Select all

::selectitems "<curpath>\somefile",, 1;//will select and focus somefile
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

lian00
Posts: 429
Joined: 09 Jul 2014 17:12

Re: [solved] goto last file labelled green

Post by lian00 »

Thanks. I will try to polish this code with your suggestion.
Windows 10 64 bits

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

Re: [solved] goto last file labelled green

Post by highend »

selectitems doesn't scroll a file into few, so there is no jump included...
One of my scripts helped you out? Please donate via Paypal

Post Reply