mirror of
https://github.com/sbrl/bin.git
synced 2018-01-10 21:33:46 +00:00
Upgrade organise-photos to add options
This commit is contained in:
parent
af6db0b49e
commit
55b24b1f34
1 changed files with 32 additions and 1 deletions
|
@ -4,7 +4,31 @@
|
||||||
# organises them into a folder structure based on the month and year
|
# organises them into a folder structure based on the month and year
|
||||||
# they were last modified (taken).
|
# they were last modified (taken).
|
||||||
|
|
||||||
for filename in *.jpg *.mp4
|
DRY_RUN=false
|
||||||
|
|
||||||
|
while test $# -gt 0
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
--help)
|
||||||
|
echo organise-photos
|
||||||
|
echo " by Starbeamrainbowlabs <feedback@starbeamrainbowlabs.com>"
|
||||||
|
echo "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)."
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " --help"
|
||||||
|
echo " Show this help message"
|
||||||
|
echo " --dry-run"
|
||||||
|
echo " Do a dry run - don't actually move any files."
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
--dry-run)
|
||||||
|
echo Activating dry run mode.
|
||||||
|
DRY_RUN=true
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
find . -maxdepth 1 \( -iname "*.jpg" -o -iname "*.mp4" \) -print0 | while read -r -d '' filename
|
||||||
do
|
do
|
||||||
echo -ne "Processing ${filename} - ";
|
echo -ne "Processing ${filename} - ";
|
||||||
takenYear=$(date -r "${filename}" +%Y);
|
takenYear=$(date -r "${filename}" +%Y);
|
||||||
|
@ -16,6 +40,11 @@ do
|
||||||
|
|
||||||
echo -ne "filing in ${newFolder} - ";
|
echo -ne "filing in ${newFolder} - ";
|
||||||
|
|
||||||
|
if [ "$DRY_RUN" = true ] ; then
|
||||||
|
echo dry run
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "${newFolder}";
|
mkdir -p "${newFolder}";
|
||||||
mv "${filename}" "${newFilename}";
|
mv "${filename}" "${newFilename}";
|
||||||
|
|
||||||
|
@ -23,3 +52,5 @@ do
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "*** Complete! ***"
|
echo "*** Complete! ***"
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue