moving files into a directory based on year (mac)


#!/bin/bash

find . -maxdepth 1 -type f -newermt '2020-01-01' ! -newermt '2021-01-01' -print0 | while read -d $'\0' file; do
    year=$(date -r "$file" +%Y)
        mv "$file" "$year/"
done```