Page 1 of 2

[solved] goto last file labelled green

Posted: 04 Dec 2015 17:15
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...

Re: goto last file labelled green

Posted: 04 Dec 2015 17:54
by highend
goto "your file name"; scrolls a file into view (if that's what you mean).

Re: goto last file labelled green

Posted: 04 Dec 2015 18:09
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.

Re: goto last file labelled green

Posted: 04 Dec 2015 19:23
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;

Re: goto last file labelled green

Posted: 04 Dec 2015 22:35
by lian00
I will try your script. There is one thing I know: I know the directory - it's my work directory.

Re: goto last file labelled green

Posted: 05 Dec 2015 07:41
by bdeshi
highend, tag.dat lists files alphabetically by path.

Re: goto last file labelled green

Posted: 05 Dec 2015 09:18
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...

Re: goto last file labelled green

Posted: 05 Dec 2015 10:58
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;

Re: goto last file labelled green

Posted: 05 Dec 2015 14:21
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.

Re: goto last file labelled green

Posted: 05 Dec 2015 14:33
by highend
You mean something like this?

Code: Select all

    goto "E:\telechargement\photos-xz\2014?lbl:green";
    goto gettoken("<allitems |>", -1, "|");

Re: goto last file labelled green

Posted: 05 Dec 2015 14:42
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 ?

Re: [solved] goto last file labelled green

Posted: 05 Dec 2015 14:54
by lian00
OK, my script works as intended. I suppose it's very bad code but it works :-) as needed for me.

Re: [solved] goto last file labelled green

Posted: 05 Dec 2015 14:58
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

Re: [solved] goto last file labelled green

Posted: 05 Dec 2015 15:44
by lian00
Thanks. I will try to polish this code with your suggestion.

Re: [solved] goto last file labelled green

Posted: 05 Dec 2015 16:04
by highend
selectitems doesn't scroll a file into few, so there is no jump included...