Rule to tag items with author or date (both are in Name)

I have a database with over 1000 articles, all of which are named Author Last Name Year - Article Title. e.g., Berry 1987 - Preserving Wildness

I would like to be able to search by both Author and Year, so I figure putting one of them in Metadata (I see there’s an Author field available) or as a tag that could then be sorted upon would do.

It seems the “Unify Date In Names” rule might help. How might I go about editing this rule (or creating a new one) to get this functionality? Thanks!

1 Like

My go-to tool is Applescript; others can advise on smart rules and regex

Is your naming structure consistent; first word Author, 2nd word Year?

I use a set of author tags; Author-aaaaaaa

If you’re only doing a search, you don’t need a smart rule. A smart group should be sufficient.

And in what way are you trying to utilize a smart object like this? Creating a smart group of an Author then searching it by year?

Here is an example local smart group…

And a toolbar search on that smart group, looking for a partial date contained in the name…

Let’s say I have a group (e.g., “The history of the attention economy” or I’m searching for something e.g., “contempla*” I’d like to sort results by author (I can do this already because of the way I’ve named files), but I’d also like to sort thing by year to see the chronology of things.

Your example would still only require a smart group since you’re only using it for search purposes. Results in a smart group can be sorted lust like the item list can. See View > Sort.

It currently not possible to sort on two criteria.

I wouldn’t need to sort on two at the same time. I’d just need to sort on either.

How would I sort on date in this scenario?

It seems to me that I could smartly assign a tag, such as the year of publication picked from the file name (e.g., 1987 in the Berry example referenced above) and therefore search on Name or Tag and it would give me what I want.

If the date is not at the beginning of the name - as it clearly isn’t in your example, you wouldn’t be able to do a date sort.

Tags would only be date sortable if they were the only tags on the files.

If you’re using the Pro or Server editions, you could assign a relative date as custom metadata, e.g., 1987. You can shown the metadata as a column in the list view and sort on it.

I would suggest you use Single-Line Text as the data type since you’re just wanting to enter the year.

Agreed.

What I would like to know is if I can use a smart rule to assign Publication Year automatically from the year in Name? And if so, what that smart rule might contain.

Or am I misunderstanding how smart rules work?

Thanks!

Actually, this is where a smart rule could work!

  • I’m targeting a specific group here, but this could target a database as well.

  • I’m looking for any document whose Publication Year is empty and has four successive digits in the name.

  • Since you aren’t using a full date, you can’t use the Scan Date action. In this case a regular expression is used.

    • .* (including a space at the end) looks for anything up to the first space. The ^ says to start at the beginning of the string.
    • \d{4} looks for four digits. Putting this in parentheses creates a capturing group, meaning “keep this is you find a match”.
  • The Change Publication Year action uses the first captured group - \1 - to apply the found four digits as the value for the custom metadata.

5 Likes

This is SO helpful, thank you! Will try it out and report back.

At your leisure and convenience :slight_smile:

2 Likes

Will this work if publication date was a metadata date format field or only if it’s single line text?
I think I tried doing this with a years worth of receipts with yyyymmdd at the end of the name and putting that date into a custom metadata date field but couldn’t at the time. Maybe over a year ago.
Has this changed?

The Scan Name action is fairly recent, so maybe it’s worth giving that a try.

It worked!! This will be so helpful to me. Thank you again!!

3 Likes

Thanks for the Publication Date extract solution and regex explanation

Do you have an Author extract solution?
I notice in the screenshot Author might be multiple instead of a single word
My scripting solution would be all text preceding the 4 digit year

2 Likes

You’re very welcome :relaxed:

Custom metadata with a Date data type will not conform to a user-defined format. If you want a specific format, use Single-Line Text.

Multiple authors already works in the regular expression.

Here is a modification that gets the Author and Publication Year from the name (remembering this is conforming to @beck’s nomenclature) and it enters both as custom metadata…

Notice I didn’t have to use multiple Scan Name actions. I used two capturing groups and just applied each to its respective Change <metadata>.

4 Likes