#!/usr/bin/env bash # This script takes all the jpg and mp4 files in a directory and # organises them into a folder structure based on the month and year # they were last modified (taken). for filename in *.jpg *.mp4 do echo -ne "Processing ${filename} - "; takenYear=$(date -r "${filename}" +%Y); takenMonth=$(date -r "${filename}" +%-m); takenMonthText=$(date -r "${filename}" +%B); newFolder="${takenYear}/${takenMonth}-${takenMonthText}/"; newFilename="${newFolder}${filename}"; echo -ne "filing in ${newFolder} - "; mkdir -p "${newFolder}"; mv "${filename}" "${newFilename}"; echo Done\!; done echo "*** Complete! ***"