Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle files and photos which are in a defined range of dates #218

Open
rafo opened this issue Jun 4, 2022 · 1 comment
Open

Handle files and photos which are in a defined range of dates #218

rafo opened this issue Jun 4, 2022 · 1 comment

Comments

@rafo
Copy link

rafo commented Jun 4, 2022

Is your feature request related to a problem? Please describe.

I try to move pictures from one Holyday into one folder. I just need to know from which date till when my holyday took place.

Describe the solution you'd like

Add the strings rangeCreated rangeModified exif
to the mode-parameter from the created filter

To define that you are searching for files created (modified == rangeModified) between e.g 2021-12-23 and 2021-12-26 and you want to move them in one folder, you could simply:

rules:
  - name: Christmas Wishlists
    locations: "~/Desktop"
    filters:
      - created:
          start: 2021-12-12
          end: 2021-12-20
          mode: rangeCreated
    actions:
      - move: "~/Lists/{created.start.year}/{name}-{created.start}-{created.end}/"

And for pictures, you could simply:

rules:
  - name: Christmas photos
    locations: "~/Desktop"
    filters:
      - created:
          start: 2021-12-23
          end: 2021-12-26
          mode: exif
    actions:
      - move: "~/Pictures/{created.start.year}/{name}-{created.start}-{created.end}/"

Describe alternatives you've considered
Maybe just use the python extension.

Additional context
Pandas is great for time series in general, and has direct support for date ranges. For example pd.date_range().

"Returns the range of equally spaced time points [...] such that they all satisfy start <[=] x <[=] end"

Maybe this could help?

@xdhmoore
Copy link
Contributor

xdhmoore commented Jun 5, 2022

The following seems to work for me for last modified time using a python filter:

#  organize run .\time_test.yaml --working-dir .

rules:
  - name: "test"
    locations: .
    filter_mode: all
    filters:
      - extension: "txt"
      - python: |
         import datetime
         start = datetime.datetime(2022, 6, 2 , 0, 0, 0).timestamp()
         end = datetime.datetime(2022, 6, 4 , 20, 42, 0).timestamp()

         return start < path.stat().st_mtime < end

    actions:
      - echo: "matched"

It looks like st_ctime may work for creation time depending on your OS.

It also looks like this project already has Pillow as a dependency, so maybe extracting exif data in a filter may not be much harder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants