1
0
Fork 0
mirror of https://github.com/sbrl/bin.git synced 2018-01-10 21:33:46 +00:00
bin/organise-photos

26 lines
645 B
Text
Raw Normal View History

2017-01-04 14:55:14 +00:00
#!/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! ***"