tfeldmann / organize

The file management automation tool.
http://organize.readthedocs.io
MIT License
2.32k stars 134 forks source link

Consistent chronological order Issue in File Renaming #354

Closed iburunat closed 8 months ago

iburunat commented 9 months ago

Describe the bug I consistently face an issue where file renaming with counter (on_conflict: rename_new) results in an order that doesn't align with the original chronological sequence, but a random order, of the files.

Environment

Your config file The first rule involves resizing an image with the "_r" suffix, transferring metadata from the original file to the newly resized file, synchronizing the timestamp of the resized file with the original file's, moving the original file to the Trash, and ultimately removing the "_r" suffix from the preprocessed file, thereby replacing the original image with the resized version.

The second rule renames the preprocessed photos with year-month-day_counter and sorts them in date folders. Here the counter seems to be random.


# ----------------------------------------------------------------------------------|
  - name: "{IMAGES} {processing + moves to folder2}"
    locations:
      - path: '~/Pictures/album/folder1/'
    subfolders: false
    enabled: true
    filters:
      - extension:
          - jpg
          - png
          - jpeg
          - heic
    actions:
      - shell: |
          magick "{path}" -resize '1440x1440>' "{path.parent}/{path.stem}_r.{extension.lower()}"
          exiftool -tagsFromFile "{path}" "{path.parent}/{path.stem}_r.{extension.lower()}"
          touch -r "{path}" "{path.parent}/{path.stem}_r.{extension.lower()}"
          mv "{path.parent}/{path.stem}_r.{extension.lower()}_original" ~/.Trash
          mv "{path}" ~/.Trash
          mv "{path.parent}/{path.stem}_r.{extension.lower()}" "{path.parent}/{path.stem}.{extension.lower()}"
      - move:
          dest: "~/Pictures/album/folder2/"
          on_conflict: rename_new
          rename_template: "{name}_{counter}{extension}"
# ----------------------------------------------------------------------------------|
  - name: "{IMAGES} {renames & moves to specific date folder}"
    locations:
      - path: '~/Pictures/album/folder2/'
    subfolders: false
    enabled: true
    filters:
      - created
      - extension:
          - jpg
          - png
          - jpeg
          - heic
    actions:
      - move: # and rename
          dest: "~/Pictures/album/{created.strftime('%Y-%m-%d')}/{created.strftime('%Y-%m-%d')}.{extension.lower()}"
          on_conflict: rename_new
          rename_template: "{name}_{counter}{extension}"
tfeldmann commented 9 months ago

Thanks for the detailed report. What do you mean by the counter being "random"? The files are handled in the order they are visited, which depends on the filesystem and is not always alphabetically correct.

iburunat commented 8 months ago

Exactly. So for instance, my list of photos is this one:

Screenshot 2024-02-18 at 20 50 42

Which after the processing gets converted into this:

Screenshot 2024-02-18 at 20 50 55

However, the rearranged photos deviate from the original sequential (chronological) order. Consequently, when navigating through the converted photos, they exhibit time jumps, creating a rather frustrating browsing experience.

Is there a way to tell Organize to follow a strict handling order?

tfeldmann commented 8 months ago

I see the problem. This should really be handled in alphabetical order. I'm on it.

iburunat commented 8 months ago

Thank you! I intended to mean alphabetical order, as the photo file names naturally align with the chronological order.

tfeldmann commented 8 months ago

I decided to use natsort for this, so the files are sorted just like in the system file explorer. The fix is already on the main branch and will be released soon. Thanks again for the issue!

tfeldmann commented 8 months ago

Just released the fixed version in v3.2.1