0

Is it possible to use a Finder search to display all files created on a Monday, or on a Tuesday, etc.?

1
  • What a curious manner to slice the data files on a computer. I could see using AppleScript to generate smart searches to cover a small range of Mondays but since the day of the week is localized text and changes relative to the current system time zone (as opposed to what day it was when it was written to storage), it’s generated by SDK and not written directly to the metadata store for each file. You’ll probably need to write your own tool if you do intend to have 20 years of Mondays searchable…
    – bmike
    Commented Jan 30 at 21:57

2 Answers 2

1

If you have Python 3 installed, this kind of thing may help:

  • Substitute a folder path with a string literal instead of os.path.dirname(__file__)

    • e.g. '/'. It will traverse the hierarchy of folders. Hasn't been tested for things like read rights - you may have some system folders it wouldn't let you traverse.
    • But try some place like Documents folder. It has to be an absolute path. So '/Users/<profile>/Documents'
  • and a day of week eg 'SUN' instead of 'MON' etc.

The script could be easily modified to add command line arguments (see sys.argv).

But it's enough to get you started.

__author__ = 'Jeremy Gordon Flowers'

from typing import List

def cls() -> None:
    from os import system, name
    clr = 'cls' if name == 'nt' else 'clear'
    system(clr)

def get_files_for_dow(dir_path:str, dow:str) -> List[str]:
    #https://docs.python.org/3/library/datetime.html#datetime.datetime.weekday
    # 0 = MON, 6 = SUN
    DOW = ['MON','TUE','WED','THU','FRI','SAT','SUN']
    weekday = DOW.index(dow)
    results = []
    import os
    import datetime
    from pathlib import Path
    for (dir_path, dir_names, file_names) in os.walk(dir_path):
        for f in file_names:
            fn = os.path.join(dir_path,f)
            #https://docs.python.org/3/library/os.path.html#os.path.getctime
            fd = os.path.getctime(fn)
            d = datetime.datetime.fromtimestamp(fd)
            if d.weekday() == weekday:
                results.append(fn) 
    return results

def main() -> None:
    cls()
    import os
    for f in get_files_for_dow(os.path.dirname(__file__), 'MON'):
        print(f)

if __name__ == '__main__':
    main()
4
  • Probably better to have the script call an xattr to dump a Monday tag on the file. Then spotlight can search for them (and they’ll pop up immediately in any running query or Smart Folder).
    – bmike
    Commented Feb 25 at 23:02
  • @bmike AFAIK xttr doesn't allow date arithmetic to do days of the week. How is that any better than os.path.getctime? And isn't tagging a manual process?
    – JGFMK
    Commented Feb 26 at 0:11
  • I mean to write either kMDItemKeywords or finder comments to add Monday, Tuesday, Wednesday, etc… and have your script modify the metadata for each file it finds rather than spitting out a list of files. Your script is awesome, and it could enable spotlight to be super and maybe do an idempotent write of metadata in case OP sets it up on cron to keep the index relatively fresh at all times.
    – bmike
    Commented Feb 26 at 0:14
  • @bmike Got you. You could use this to periodically assign the meta tags.
    – JGFMK
    Commented Feb 26 at 7:19
0
  1. Search something in Finder
  2. Click on the circle with three dots.
  3. In the drop-down menu that appears, select Show Search Criteria
  4. A bar will appear with three drop-down buttons.
  5. Click the first drop-down button and select Created Date.
  6. Click the second drop-down button and select exactly.
  7. Click the third drop-down button and select your desired date.
  8. Replace your "something" from Step 1 with what you actually want to search.
5
  • That works to search for a specific date, not for a named day of the week.
    – user279030
    Commented Jan 5, 2023 at 16:00
  • Yeah, I think that's as far as Finder allows you to go. You'll just have to click it multiple times. There's a plus sign to the right of the date, so you can click it and search multiple Mondays at a time.
    – ILEM World
    Commented Jan 5, 2023 at 16:00
  • Manually looking up the date for every Monday of every week for the past 20 years and plugging that in, one by one, to a Finder query. Uhhhh, no.
    – user279030
    Commented Jan 5, 2023 at 16:11
  • Yeah, it's unfortunate.
    – ILEM World
    Commented Jan 5, 2023 at 16:11
  • This answer doesn't give specific weekday. Furthermore it doesn't work for Monterey 12.7.3.. In a similar fashion, to this answer, it's best to enter a character such a in the magnifying/search option, then click +.. The you can select Created Date, Today etc from combo boxes. Then remove the a from the search.
    – JGFMK
    Commented Feb 25 at 20:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .