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

Add organise-photos

This commit is contained in:
Starbeamrainbowlabs 2017-01-04 14:55:14 +00:00
parent 61a2a52fb1
commit 1a9ee0496d
2 changed files with 26 additions and 0 deletions

View file

@ -39,6 +39,7 @@ Here's a list of the most interesting ones, along with what they do and where th
- [tldr](https://github.com/raylee/tldr) - A bash client for - [tldr](https://github.com/raylee/tldr) - A bash client for
[tldr-pages](https://github.com/tldr-pages/tldr). [tldr-pages](https://github.com/tldr-pages/tldr).
- [git ignore](https://gitignore.io/) - A really useful subcommand for git that allows you to generate ignore files automagically. - [git ignore](https://gitignore.io/) - A really useful subcommand for git that allows you to generate ignore files automagically.
- organise-photos - A small bash script I wrote that organises the photos in a directory by year & month.
## Disclaimer ## Disclaimer
I don't own many of the tools in this repository. If you are an owner of one of these tools and I haven't linked to you, please let me know as I probably forgot. I don't own many of the tools in this repository. If you are an owner of one of these tools and I haven't linked to you, please let me know as I probably forgot.

25
organise-photos Executable file
View file

@ -0,0 +1,25 @@
#!/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! ***"