Page 1 of 2

TagCounter

Posted: 25 Feb 2012 20:03
by serendipity
Counts Labels, Comments and Tags

Code: Select all

//TagCounter
//Counts Labels, Comments or Tags in "My computer"
"Label"
  global $lookup, $lookup2;
  $lookup=Label;
  $lookup2=lbl;
  sub "_getcount";

"Comment"
  global $lookup, $lookup2;
  $lookup=Comment;
  $lookup2=cmt;
  sub "_getcount";

"Tags"
  global $lookup, $lookup2;
  $lookup=Tags;
  $lookup2=tags;
  sub "_getcount";

"_getcount"
  global $lookup, $lookup2;
  $tab= tab ("get");
  
  goto "%computer%?$lookup2:?*"; 
  setting "SortFoldersApart",0;
  setting "KeepFoldersOnTop",0;
  sortby $lookup, a;
  $tags = report ("{$lookup}|"); 
  $tags = formatlist($tags,"ed","|");
  $lblcount= gettoken($tags, "count","|");
  $count=1;
  $report="";
  WHILE($count<=$lblcount){
    $filter=gettoken($tags, $count,"|");
    selfilter $filter,,"$lookup";
    $filtercount=<get countselected>;
    $report= "$report<crlf>$filter=$filtercount";
    $count++;
    }
  filter;
  $list= formatlist($report,"e","<crlf>");
  $total=<get countitems>;
  seltab $tab;
  text "Total=$total<crlf><crlf>$list";
  

Update: changed search to variable %computer%
Update 2: Added total count

Bug fix (31Mar2012): Fixed a bug with sorting folders apart

Re: TagCounter

Posted: 30 Mar 2012 07:32
by paul0
Great job. :appl:

Can we list a little more information about the tags, labels & comments?

For example, a brief file/folder list of each label, tag, and comment.

Then, the script will have more powerful function, called Tag Summary :appl:

it can be a readable and informative version of tag.dat:-)

Thank you for sharing.

Re: TagCounter

Posted: 30 Mar 2012 07:44
by paul0
There is a potential bug. One tag shows twice. Please see the attachment.

Re: TagCounter

Posted: 30 Mar 2012 17:40
by serendipity
paul0 wrote:There is a potential bug. One tag shows twice. Please see the attachment.
Strange, what do you get when you paste this in Addressbar:

Code: Select all

My Computer?tags:?*
Do you see 12 items or 8?

As to your suggestion for Tag summary, XY already does this with its search. Again, you'll see that when you paste the above code.

Re: TagCounter

Posted: 31 Mar 2012 00:06
by paul0
serendipity wrote: Strange, what do you get when you paste this in Addressbar:

Code: Select all

My Computer?tags:?*
Do you see 12 items or 8?
I see 12. The total number is correct.

Re: TagCounter

Posted: 31 Mar 2012 00:10
by serendipity
paul0 wrote:
serendipity wrote: Strange, what do you get when you paste this in Addressbar:

Code: Select all

My Computer?tags:?*
Do you see 12 items or 8?
I see 12. The total number is correct.
OK, I'll see whats going on.

Re: TagCounter

Posted: 31 Mar 2012 02:52
by serendipity
I tested this but cannot reproduce, to that end I tagged some files with exact same tags you have and still cannot reproduce.
my script simply gets info from XY's search result:

Code: Select all

My Computer?tags:?*
I checked my script again and don't see what can go wrong.
Are you sure you can reproduce this? Maybe be restart XY and try again? No idea otherwise.

Re: TagCounter

Posted: 31 Mar 2012 05:53
by paul0
XYplorer has been restarted. The bug can still reproduce here.

At the same time, I have cleaned up orphans using xyplorer tag setting (see attached picture)

Re: TagCounter

Posted: 31 Mar 2012 06:21
by paul0
Here is a possible reason.

Here is a screenshot of step through dialog. Please make sure it takes two group of remove tags as the same tag.

Re: TagCounter

Posted: 31 Mar 2012 06:27
by paul0
Find an error here:

Re: TagCounter

Posted: 31 Mar 2012 07:15
by serendipity
Interesting:
Can you try this:
1) My Computer?tags:?*
2) Sort list ascending in tags column.
3) are the "remove" tags separate or together?

I am asking this because my script simply takes XY's sort order and uses that list and formats it.

Re: TagCounter

Posted: 31 Mar 2012 07:26
by paul0
serendipity wrote:Interesting:
Can you try this:
1) My Computer?tags:?*
2) Sort list ascending in tags column.
3) are the "remove" tags separate or together?

I am asking this because my script simply takes XY's sort order and uses that list and formats it.
It is wired. It cannot sort properly. Please see the attached screenshot.

Re: TagCounter

Posted: 31 Mar 2012 07:32
by paul0
a new discovery.

The sorted results are group by folders and files.

The first 8 items are folders and the last four are files. Does this make sense now:-)

Re: TagCounter

Posted: 31 Mar 2012 17:04
by serendipity
paul0 wrote:a new discovery.

The sorted results are group by folders and files.

The first 8 items are folders and the last four are files. Does this make sense now:-)
Aah ofcourse! :oops: i forgot to disable sort folders apart and keep folders on top.

Try the script now.

Re: TagCounter

Posted: 31 Mar 2012 22:05
by paul0
Yeah, working now :biggrin: