#!/bin/sh find . -maxdepth 1 \ | grep -v ^.$ \ | grep -v "Telegram" \ | grep -v "Screenshots" \ | grep -v "OLD-"\ | while read file do date="$(stat -f "%Sm" -t %Y-%m "$file" )" [ -f "OLD-$date" ] && mkdir -p OLD-$date mv "$file" OLD-$date/ done echo done.