I am looking for a new explorer, and seems like XYplorer is the best one out there. It meets all my requirements, but I am not sure about the following one. Can it do this?:
- Sort folders by a file's tags in each sub-folder
Details:
Folder-1
-Subfolder-1
---File.doc (Tag =b-text)
-Sub-folder-2
---File.doc (Tag =a-text)
-Subfolder-3
---File.doc (Tag =c-text)
I would like to see Folder-1 listing as:
-Subfolder 2
-Subfolder 1
-Subfolder 3
Sort folders by a file's tags in each sub-folder
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Sort folders by a file's tags in each sub-folder
You need to use a custom column.
My solution will only be helpful if your "file.doc"s are direct children of "subfolder"s (not located deeper than outlined) and have only one tag.
WARNING: This can make browsing in XYplorer slow if you have a lot of files in a lot of folders, and a lot of those folders in the active view.
first copy the following code.Now enter the following code into the addressbar and press ENTER. (Make sure the previous code is still copied to clipboard before pressing ENTER)
now add a new column to the list :Menu -> View -> Columns -> Add Column. A new (Undefined) column will be added to the view.
Right click on it's title/header, choose "Select Custom Column", then pick "1st Child Tag".
Info: this column script will parse all children of a listed folder, get the first child that is tagged (if any), and return the first tag of that child.
It can be modifed to return ALL tags of the first tagged child of a listed folder. Look in the script.
It can also be modified to match the tags of all children against a taglist, and only return matched tags.
If can also be modified... you get the idea.
ed: Yay, my 1-and-a-half-thousand-th post!
My solution will only be helpful if your "file.doc"s are direct children of "subfolder"s (not located deeper than outlined) and have only one tag.
WARNING: This can make browsing in XYplorer slow if you have a lot of files in a lot of folders, and a lot of those folders in the active view.
first copy the following code.
Code: Select all
Snip: CustomColumn 1
XYplorer 14.80.0225, 2/4/2015 12:29:43 AM
Action
ConfigureColumn
Caption
1st Child Tag
Type
3
Definition
//returns the first tag of the first tagged first-level child
$lst = listfolder(<cc_item>);
foreach($itm,$lst){
$t = gettoken(tagitems(tags,,$itm),1,",");
//$t = tagitems(tags,,$itm);
//the line above will return all tags of first tagged child if you remove it's preceding //
if ($t != ""){ break; }
}
return $t;
Format
0
Trigger
1
Item Type
1
Item Filter
Code: Select all
::snippet <clipboard>;Right click on it's title/header, choose "Select Custom Column", then pick "1st Child Tag".
Info: this column script will parse all children of a listed folder, get the first child that is tagged (if any), and return the first tag of that child.
It can be modifed to return ALL tags of the first tagged child of a listed folder. Look in the script.
It can also be modified to match the tags of all children against a taglist, and only return matched tags.
If can also be modified... you get the idea.
ed: Yay, my 1-and-a-half-thousand-th post!
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: Sort folders by a file's tags in each sub-folder
The listing in the first post has the tagged item always being named 'File.doc'.
If that is indeed true then this can obviously be shortened dramatically and the impact to browsing would be significantly reduced.
If that is indeed true then this can obviously be shortened dramatically and the impact to browsing would be significantly reduced.
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Sort folders by a file's tags in each sub-folder
Yeah.
@Imagine: if that is indeed the case, then you can replace the part between (and icluding) Definition and Format with:
Code: Select all
Definition
$i = "<cc_item>\File.Doc"; if (exists($i)==1){return gettoken(tagitems(tags,,$i),1,",")}
FormatIcon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
Imagine
- Posts: 8
- Joined: 03 Feb 2015 18:37
Re: Sort folders by a file's tags in each sub-folder
Thanks @SammaySarkar and @TheQwerty.
I will keep the file names standard (file.doc). I realized that the file would have more than one tags (e.g. Title, Owner, Category, etc). Say if I want to do a sort first by tag "Title" and then do a second sort by "Category", how would you modify the script?
Thanks!
I will keep the file names standard (file.doc). I realized that the file would have more than one tags (e.g. Title, Owner, Category, etc). Say if I want to do a sort first by tag "Title" and then do a second sort by "Category", how would you modify the script?
Thanks!
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: Sort folders by a file's tags in each sub-folder
You have to use a fixed set of tags for each category for this to work.
Say you use the strings "Title_A", "Title_B" as the Title tag types. This custom column script will return first child tag matching these tags.
You can create additional columns for other tag categories.
Create a few copies of this column (just follow steps in my post above a few times) Find them in Tools -> Config -> Custom Columns.
modify the column title, paste the following as the script for each column, and modify $tags list (in the script) for each tag category.
Say you use the strings "Title_A", "Title_B" as the Title tag types. This custom column script will return first child tag matching these tags.
You can create additional columns for other tag categories.
Create a few copies of this column (just follow steps in my post above a few times) Find them in Tools -> Config -> Custom Columns.
modify the column title, paste the following as the script for each column, and modify $tags list (in the script) for each tag category.
Code: Select all
//return first matching $tag of first child
$tags = "Title_A|Title_B";
$i = "<cc_item>\File.doc";
if (exists($i)==1){return regexmatches(replacelist(tagitems(tags,,$i),", |,","<crlf>|<crlf>"),"^($tags)$")}
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
XYplorer Beta Club