INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: How to create a Pane Category to group by Date Imported  (Read 21507 times)

Afrosheen

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 313
How to create a Pane Category to group by Date Imported
« on: December 31, 2015, 02:47:13 am »

I need some help in creating a view where I can set up a list of groups based on the date imported of the files.  Ideally I'd like to create the following groupings under the Date Imported category:

Imported Today;
Imported This Week;
Imported Last Week;
Imported This Month;
Imported Last Month;
Imported This Year;
Imported Last Year;

Thanks for the consideration.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #1 on: December 31, 2015, 09:43:24 am »

You can definitely do this with a Categories or Panes view.  To me personally, it makes more sense to use a Panes view for this, because it's easier to switch back and forth, and easier to see your files immediately.  But Categories definitely works if you want that.

The key here, that isn't all that well documented, is to use a Search List as one of your Categories or Panes.  Marko's tutorial on views taught me how to use them:

http://yabb.jriver.com/interact/index.php?topic=68960.0

Essentially, instead of just displaying a library field, you can display a pane (or category) that has selections for one or more saved searches.  These saved searches are called a Search List.  You select that as the type when creating your category or Pane.  So you can create a Pane (or category) called "Import Range" and then populate it with searches for Today, This week, This Month, etc.  The criteria for these searches are mostly pretty straight forward.  Something like:  [Date Imported] "is in the last" 7 days .

This is actually an extremely powerful feature that let's you do some pretty sophisticated things.  These Panes can be used as toggle switches, or multi-selects to turn on and off view features and searches.  They can be cascaded of course by using multiple panes of this type.  I sometimes add a Pane to the end of one that I use for tagging (or otherwise) that I want to sometimes view as random.  This last pane just has a saved search of "shuffle".  When I click the ON button, it shuffles.  When I click off of it, it's not shuffled.  Just a simple example.

If this isn't clear, or you need more help, please ask.  Good luck!

EDIT:  Added screen shot of example Panes view with Search List.

Brian.
Logged

Afrosheen

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 313
Re: How to create a Pane Category to group by Date Imported
« Reply #2 on: December 31, 2015, 12:29:48 pm »

This is very cool!!!! Thank you @bigentry for laying this out so nicely!!!!  I'm going to be spending the rest of this weekend developing better views.  Thank you!!
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #3 on: December 31, 2015, 02:51:57 pm »

Glad I could help out.  Let us know how your View changes and tweaks go.  :)

Brian.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #4 on: January 01, 2016, 12:00:40 am »

One of the beauties of the search list is that you can specify different sort parameters for each entry, if you want to.

Also, regarding "Imported today"...
If you use the simple approach of "in the last 24 hours" you will inevitably draw in files that were actually imported yesterday. If you use something like this instead though...
[=isequal([date imported],formatdate(now(),dd//MM//yyyy),8)]=1

it compares the current date against [date imported] and only includes those that match, resulting in a true "Imported Today" listing.

You can also use:
[=isequal([date imported],formatdate(math(now()-1),dd//MM//yyyy),8)]=1

to give you a true "Imported Yesterday" listing.
***Bear in mind that these two strings assume that your system displays dates the British (proper ;)) way. If your locale uses a different format, massage the "dd//MM//yyyy" bit to match the way your system displays dates.***

Happy New Year to you all,

-marko

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #5 on: January 01, 2016, 12:07:24 am »

This is very cool!!!! Thank you @bigentry for laying this out so nicely!!!!  I'm going to be spending the rest of this weekend developing better views.  Thank you!!
Because my mind lives in the gutter, this made me chuckle :D

Thanks blgentry :)

Afrosheen

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 313
Re: How to create a Pane Category to group by Date Imported
« Reply #6 on: January 01, 2016, 02:33:04 am »

Oops… I guess I need to schedule that eye exam now.  :P

One of the beauties of the search list is that you can specify different sort parameters for each entry, if you want to.

Also, regarding "Imported today"...
If you use the simple approach of "in the last 24 hours" you will inevitably draw in files that were actually imported yesterday. If you use something like this instead though...
[=isequal([date imported],formatdate(now(),dd//MM//yyyy),8)]=1

it compares the current date against [date imported] and only includes those that match, resulting in a true "Imported Today" listing.

You can also use:
[=isequal([date imported],formatdate(math(now()-1),dd//MM//yyyy),8)]=1

to give you a true "Imported Yesterday" listing.
***Bear in mind that these two strings assume that your system displays dates the British (proper ;)) way. If your locale uses a different format, massage the "dd//MM//yyyy" bit to match the way your system displays dates.***

Happy New Year to you all,

-marko

This is where I need to focus my attention.  Though right now I have no idea where to input the search string that you've shared.  But this is exactly what I am looking for. 
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #7 on: January 01, 2016, 05:29:32 am »

So, you add your search list category to the view, then when adding the searches, place the strings in as custom rules, or hit "Import / Export" and paste them in there.

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #8 on: January 01, 2016, 09:54:40 am »

Quote
@bigentry
Because my mind lives in the gutter, this made me chuckle :D

That mistake has been made more often than I would have expected, starting about 16 or 17 years ago at a company I used to work for.  One person *insisted* that was my email address, even after being corrected.  :)

Makes me chuckle too.

Brian.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #9 on: January 01, 2016, 11:01:22 am »

One of the beauties of the search list is that you can specify different sort parameters for each entry, if you want to.

That's strange that you should mention that.  Just yesterday I changed up one of my Movies views to sort in several different ways.  This is MUCH faster than clicking through the menus up top trying to find the sorting option you want.

I also combined searching and filtering for one of them.  For my movie series (like Harry Potter, etc), I have a sort button that filters out everything other than movie series and then sorts them by series title and then in order within the series.  This is cool stuff!

Brian.
Logged

Afrosheen

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 313
Re: How to create a Pane Category to group by Date Imported
« Reply #10 on: January 01, 2016, 05:36:26 pm »

Hmm, the search string isn't working.  Is there a wikipage where I can learn to decipher the different parts of the string?  For instance, I'm not sure what the "8" is for at the end of the string or why there's a "-1" outside of the "now()" field.
Logged

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #11 on: January 01, 2016, 05:49:36 pm »

Other than the rather advanced search string that Marko gave you, is the base functionality working?  Have you created a "this month", or "last 90 days" search that works?

Brian.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #12 on: January 01, 2016, 05:58:28 pm »

Let's get it working. You're in USA, right? So you do dates the wrong way around, right? ;)

Did you change the string to match your locale?
Basically, you want to look at how MC presents the [date imported] field, and mimic that. At a guess, yours will do mm/dd/yyyy, and if that's right, your search string will look like so:
[=isequal([date imported],formatdate(now(),MM//dd//yyyy),8)]=1

and

[=isequal([date imported],formatdate(math(now()-1),MM//dd//yyyy),8)]=1

Better now?

The how and why
There is a comprehensive wiki page here: http://wiki.jriver.com/index.php/Expression_Language

"What is the "8" for?"
the function now() returns the current date and time.
the function "formatdate(now(),dd//MM//yyyy)" takes the current date and presents it as day/month/year
[Date Imported] includes the date and time of import per file. We are not interested in the time, only the date.
the function "isequal()" compares the value for [date imported] and the formatted value for "now()". The "compare" can be carried out in various ways, and here, the "8" performs a sub-string compare, so if there's a match on day/month/year, the file gets listed.

"why there's a "-1" outside of the "now()" field"
The expression engine can do math. As we want files imported yesterday, we need to match on yesterday's date. We get at that by telling MC to "now() minus 1". Any results returned should all match imported yesterday, regardless of when the expression runs.

Simples eh ;)

-marko

Afrosheen

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 313
Re: How to create a Pane Category to group by Date Imported
« Reply #13 on: January 01, 2016, 07:10:13 pm »

Thanks marko!  Your post here helped.  I wasn't sure what I was trying to model the date string to until you told me to mimic the date that MC usually has.  So for me I formatted the string to:
Code: (Today) [Select]
[=isequal([date imported],formatdate(now(),MM//dd//yy),8)]=1
Code: (Yesterday) [Select]
[=isequal([date imported],formatdate(math(now()-1),MM//dd//yy),8)]=1
Logged

Afrosheen

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 313
Re: How to create a Pane Category to group by Date Imported
« Reply #14 on: January 01, 2016, 07:24:05 pm »

If I wanted to create a string that would provide me a range of dates, i.e. this week, last week, this year, last year, how would I go about creating such a string?
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #15 on: January 02, 2016, 04:15:13 am »

This month, last month, this year, last year are relatively easy...

This week and last week though, all depend upon how you're wired. I'm going to assume the week starts on a Monday.

This has been a little interesting. Up til now, I've settled for MC's fuzzy results once the time span went to weeks, as "=<7d" was just easier.
Months have to take into account that, "01-1=12" and so on.

I'm almost done for you, can anyone tell me...
Am I correct in thinking that MACs cannot handle MC .jvi saved view files? I sincerely hope I am wrong to think that....

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #16 on: January 02, 2016, 06:28:10 am »

.... though I'm reasonably sure I'm not, so...

Here's what I have after a little playing around...

Today
Code: [Select]
[=isequal(formatdate([Date Imported,0],dd//MM//yyyy),formatdate(now(),dd//MM//yyyy),8)]=1
Yesterday
Code: [Select]
[=isequal(formatdate([Date Imported,0],dd//MM//yyyy),formatdate(math(now()-1),dd//MM//yyyy),8)]=1
This Week
Code: [Select]
[=isequal(if(isequal(formatdate([Date Imported,0],%W),00),formatdate(math([Date Imported,0]-formatdate([Date Imported,0],dd)),yyyy%W),formatdate([Date Imported,0],yyyy%W)),if(isequal(formatdate(now(),%W),00),formatdate(math(now()-formatdate(now(),dd)),yyyy%W),formatdate(now(),yyyy%W)))]=1
Last Week
Code: [Select]
[=isequal(if(isequal(formatdate([date imported,0],%W),00),formatdate(math([date imported,0]-formatdate([date imported,0],dd)),yyyy%W),formatdate([date imported,0],yyyy%W)),ifelse(isequal(formatdate(now(),%W),00),math(formatdate(math(now()-formatdate(now(),dd)),yyyy%W)-1),isequal(math(formatdate(now(),%W)-1),0),formatdate(math(now()-formatdate(now(),dd)),yyyy%W),1,math(formatdate(now(),yyyy%W)-1)))]=1
This Month
Code: [Select]
[=isequal(formatdate([Date Imported,0],MM//yyyy),formatdate(now(),MM//yyyy),8)]=1
Last Month
Code: [Select]
[=isequal(formatdate([Date Imported,0],MM//yyyy),if(isequal(formatdate(now(),MM),01),12,padnumber(math(formatdate(now(),MM)-1),2))//if(isequal(formatdate(now(),MM),01),math(formatdate(now(),yyyy)-1),formatdate(now(),yyyy)),8)]=1
This Year
Code: [Select]
[=isequal(formatdate([Date Imported,0],yyyy),formatdate(now(),yyyy),8)]=1
Last Year
Code: [Select]
[=isequal(formatdate([Date Imported,0],yyyy),math(formatdate(now(),yyyy)-1),8)]=1
It dawned on me that we can completely side-step the whole locale issue by formatting the library field too, so these should all work 'as-is', regardless of where you are.
I think there may be an issue with week numbers. I'm waiting for some feedback on this elsewhere, but for now, where week 52 or 53 spans into the new year, the new year part of the week is given week number zero. I've skirted around this for the moment by forcing "Last Week" to use week 52 if it is zero or one. This does mean that a few "Week 53's" might get lost in the listings, I'll update if I hear back on this issue. Like wise, for "This Week", it will match on week zero, missing the beginning of the week that was actually in last year.

These are for the OCD MC users amongst us. By default, the quick and easy way to do these is not as precise. 'The last week' is actually the last seven days, 'today' is actually the past 24 hours, and so on, these however, do what they say on the tin, with the small exception outlined in the "Week" searches above.
You can edit them to work with other date fields. These all use [Date Imported,0]. Switch those to [Last Played,0] to get a neat play stats view, for example.

Enjoy, give them a bash, let me know if any mistakes slipped through, or if you know of a more streamlined way to reach these target lists, please share.

-marko

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #17 on: January 02, 2016, 08:15:28 am »

I'm almost done for you, can anyone tell me...
Am I correct in thinking that MACs cannot handle MC .jvi saved view files? I sincerely hope I am wrong to think that....

JVI saved views work just fine on Macs.  I've shared one or two with Windows users and they import/export correctly.

Brian.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #18 on: January 05, 2016, 03:06:02 am »

Ahhh, nice one, thanks Brian.

I've updated the string for "Last Week" above. It now takes care of all instances of "Week Zero", returning the full week that spans the old and the new year, and should work as given, regardless of locale.

I'll get 'this week' sorted very soon. That shouldn't be as much of a headache as last week was.

-marko

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #19 on: January 06, 2016, 01:49:20 pm »

JVI saved views work just fine on Macs.  I've shared one or two with Windows users and they import/export correctly.

Brian.
The attched zip file contains two saved views based on the strings posted above. One for import stats and one for last played stats. Hopefully they'll work for all, let me know if anything isn't working.

Instructions
Download the attached zip file.
On Windows, extract the contents to: "C:\Users\[user name]\AppData\Roaming\J River\Media Center 21\Library\Saved Views"
If the saved views folder is not there, create it.

Can someone advise where these go on a MAC?

Once in place, go to MC, from the top menu choose "View > Add View > Add Library View" and use the view picker to add the views.

Enjoy.

marko.

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #20 on: January 06, 2016, 03:58:03 pm »

Can someone advise where these go on a MAC?

On a Mac you put these in:

[Your User Directory]/Library/Application Support/J River/Media Center 21/Library/Saved Views

I downloaded the views and imported them no problem.  They work as expected.  I like the Panes on the top rather than the left, so I "fixed" that.  :)  Nice work Marko.

Brian.
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How to create a Pane Category to group by Date Imported
« Reply #21 on: January 07, 2016, 04:23:26 pm »

[Your User Directory]/Library/Application Support/J River/Media Center 21/Library/Saved Views

You mean:
~/Library/Application Support/J River/Media Center 21/Library/Saved Views

You're on UNIX. Don't be a savage.  ;) :-*

Plus, when you tell them to do it that way, they can just paste the string directly into Finder > Go > Go to Folder, so you don't have to explain all of the hidden Library folder stuff.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #22 on: January 07, 2016, 04:29:06 pm »

You mean:
~/Library/Application Support/J River/Media Center 21/Library/Saved Views

You're on UNIX. Don't be a savage.  ;) :-*

Plus, when you tell them to do it that way, they can just paste the string directly into Finder > Go > Go to Folder, so you don't have to explain all of the hidden Library folder stuff.

Good point.  I've been using ~ notation since my first Unix around 1992.  But modern Mac users have no idea what's under the hood, so I try to make it easier by typing it the way I did.  But your point about cut and paste *does* make it easier, so that's worth doing.  :)

Brian.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #23 on: January 07, 2016, 07:39:43 pm »

Thanks for the MAC paths.

The logic for "Last Week" is horrible...

If [date imported] = week zero, then subtract the days to make it 31st December, then format for matching.

To match it:
If the current date is week zero, do the math to roll it back to 31st December, then subtract one from the formatted number to roll back to the previous week (usually week 51, sometimes week 52).
If the current date is week one, then "last week" is week zero, which in turn needs to roll back to 31st December, before being formatted for matching.
From week two onwards, it's all straightforward.

Anyhoo, I made a mistake that, for this year at least, has broken "Last Week" results, on just the 7th, 8th and 9th of January. For any other dates, it will be fine. Currently, it's returning week 51 from 2015 instead of week 52.

I've fixed the string in the post above and have uploaded new saved view files to the other post above.

-marko

Ferdi

  • World Citizen
  • ***
  • Posts: 195
Re: How to create a Pane Category to group by Date Imported
« Reply #24 on: April 12, 2016, 10:09:45 pm »

This is brilliant, Marko! Amazing how many great things are still to be discovered after years of using MC!
I set up the view and it works great. I also added as smart playlists to save with my iPod: I am a happy camper :D
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: How to create a Pane Category to group by Date Imported
« Reply #25 on: April 12, 2016, 10:29:35 pm »

You may want to check out this thread with related tips as well:
https://yabb.jriver.com/interact/index.php?topic=97210.msg670993#msg670993
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #26 on: September 15, 2016, 01:00:14 am »

Plus, when you tell them to do it that way, they can just paste the string directly into Finder > Go > Go to Folder, so you don't have to explain all of the hidden Library folder stuff.
What happens here, if the "Saved Views" folder hasn't been created yet?

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #27 on: September 15, 2016, 07:55:26 am »

Finder will give an error message that it can't find that folder.  Just tested on 10.9.5.  Might be different on different versions of OSX.

Brian.
Logged

marko

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 9143
Re: How to create a Pane Category to group by Date Imported
« Reply #28 on: September 15, 2016, 11:14:09 am »

I did wonder. Better to advise going one higher then?
~/Library/Application Support/J River/Media Center 2x/Library

and either enter or create Saved Views folder from there?

blgentry

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 8014
Re: How to create a Pane Category to group by Date Imported
« Reply #29 on: September 15, 2016, 12:01:19 pm »

^ Probably.  But then you need to tell them to create the directory and to make sure of the spelling (caps and spaces), etc.

Mac users are difficult to author generic instructions for because they range (seemingly) across a much more broad range of experience.  Some Mac users I've helped here seem like they just got a computer last week.  Others are firmly entrenched in Mac-ism and know all of the paradigms.  Others are more like PC convert users.  Anyway, I'm not sure what the right answer is, just sharing my thoughts.

Brian.
Logged
Pages: [1]   Go Up