mirror of
https://github.com/sbrl/bin.git
synced 2018-01-10 21:33:46 +00:00
25 lines
645 B
Bash
Executable file
25 lines
645 B
Bash
Executable file
#!/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! ***"
|