I regularly upload pictures from my families smartphone to a common upload folder. Until now the pictures are flat and unsorted within this folder.
Recently I wrote a bash script, which loops through the files, read the creation date from the exif data and moves the file into a folder structure. This word perfectly with images. I use the tool "identify" from imagemagick, which is already installed on the QNAP nas. Now I loog for a similar tool for the (mainly) MP4 files.
Any recommendations?
And for those who are interested in the script, here it is:
Code: Select all
#!/bin/bash
INPUT_DIR="/share/Pictures"
OUTPUT_DIR="/share/Pictures"
shopt -s nullglob
for filename in "$INPUT_DIR/"*.{jpg,jpeg,png,JPG,PNG}; do
imageDateTaken=$(identify -verbose $filename | grep date:modify | awk '{ print $2 }' | awk '{ print substr ($1,1,7) }')
if [ ! -d "$OUTPUT_DIR/$imageDateTaken" ]; then
mkdir $OUTPUT_DIR/$imageDateTaken
fi
cp -v $filename $OUTPUT_DIR/$imageDateTaken
rm -v $filename
done
Klaus