Created
March 25, 2025 14:52
-
-
Save adoyle/5270fd1971e02a5eb120081c3494fd66 to your computer and use it in GitHub Desktop.
Using the file date, move the file into a directory named YEAR-MON. The directory is created if it doesn't exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/local/bin/bash | |
DST_DIR=~/Photos/exports | |
# Organizes files by year/month into the DST_DIR | |
find . -type f | \ | |
while read i; \ | |
do IFS=' ' read -r -a result <<< $(ls -lUTD %Y-%m "$i");\ | |
mkdir -p $DST_DIR/${result[5]};\ | |
mv "$i" $DST_DIR/${result[5]};\ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment