some picsort stuff
This commit is contained in:
parent
0e97f9e596
commit
41430ebc2f
3 changed files with 37 additions and 25 deletions
|
@ -3,47 +3,58 @@
|
||||||
USER="$1"
|
USER="$1"
|
||||||
SOURCEPATH="/var/lib/nextcloud/$1/files/$2"
|
SOURCEPATH="/var/lib/nextcloud/$1/files/$2"
|
||||||
DESTINATIONPATH="/var/lib/nextcloud/$1/files/$3"
|
DESTINATIONPATH="/var/lib/nextcloud/$1/files/$3"
|
||||||
|
UNSORTABLEPATH="/var/lib/nextcloud/$1/files/$4"
|
||||||
|
|
||||||
echo "STARTING..."
|
echo "STARTING..."
|
||||||
|
|
||||||
|
chown -R www-data:www-data "$SOURCEPATH"
|
||||||
|
chmod -R 770 "$SOURCEPATH"
|
||||||
|
|
||||||
SCAN="FALSE"
|
SCAN="FALSE"
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for f in `find "$SOURCEPATH" -iname *.PNG -o -iname *.JPG -o -iname *.CR2 -o -iname *.CR3 -o -iname *.MP4 -o -iname *.MOV`; do
|
for f in `find "$SOURCEPATH" -iname *.PNG -o -iname *.JPG -o -iname *.CR2 -o -iname *.CR3 -o -iname *.MP4 -o -iname *.MOV`; do
|
||||||
|
SCAN="TRUE"
|
||||||
echo "PROCESSING: $f"
|
echo "PROCESSING: $f"
|
||||||
DATE=`exiftool "$f" | grep -m 1 "Create Date"`
|
DATE=`exiftool "$f" | grep -m 1 "Create Date"`
|
||||||
if ! echo "$DATE" | grep "Create Date" >/dev/null
|
if ! echo "$DATE" | grep "Create Date" >/dev/null
|
||||||
then
|
then
|
||||||
echo "SKIP: no 'Create Date' in exif ($f)"
|
RELPATH=$(realpath --relative-to="$SOURCEPATH" "$f")
|
||||||
continue
|
DIRNAME=$(dirname "$UNSORTABLEPATH/$RELPATH")
|
||||||
fi
|
echo "UNSORTABLE: $f"
|
||||||
SCAN="TRUE"
|
mkdir -p "$DIRNAME"
|
||||||
YEAR=`echo $DATE | cut -d':' -f2 | cut -c 2-`
|
mv "$f" "$DIRNAME"
|
||||||
MONTH=`echo $DATE | cut -d':' -f3`
|
|
||||||
DAY=`echo $DATE | cut -d':' -f4 | cut -d' ' -f1`
|
|
||||||
HOUR=`echo $DATE | cut -d':' -f4 | cut -d' ' -f2`
|
|
||||||
MINUTE=`echo $DATE | cut -d':' -f5`
|
|
||||||
SECOND=`echo $DATE | cut -d':' -f6`
|
|
||||||
HASH=`sha256sum "$f" | xxd -r -p | base64 | head -c 3 | tr '/+' '_-'`
|
|
||||||
EXT=`echo "${f##*.}" | tr '[:upper:]' '[:lower:]'`
|
|
||||||
if [[ "$EXT" = "cr2" ]] || [[ "$EXT" = "cr3" ]]
|
|
||||||
then
|
|
||||||
RAW="raw/"
|
|
||||||
else
|
else
|
||||||
RAW=""
|
YEAR=`echo $DATE | cut -d':' -f2 | cut -c 2-`
|
||||||
|
MONTH=`echo $DATE | cut -d':' -f3`
|
||||||
|
DAY=`echo $DATE | cut -d':' -f4 | cut -d' ' -f1`
|
||||||
|
HOUR=`echo $DATE | cut -d':' -f4 | cut -d' ' -f2`
|
||||||
|
MINUTE=`echo $DATE | cut -d':' -f5`
|
||||||
|
SECOND=`echo $DATE | cut -d':' -f6`
|
||||||
|
SECOND=`echo $SECOND | cut -d'+' -f1` # remove timezone
|
||||||
|
HASH=`sha256sum "$f" | xxd -r -p | base64 | head -c 3 | tr '/+' '_-'`
|
||||||
|
EXT=`echo "${f##*.}" | tr '[:upper:]' '[:lower:]'`
|
||||||
|
if [[ "$EXT" = "cr2" ]] || [[ "$EXT" = "cr3" ]]
|
||||||
|
then
|
||||||
|
RAW="raw/"
|
||||||
|
else
|
||||||
|
RAW=""
|
||||||
|
fi
|
||||||
|
FILE="$DESTINATIONPATH/$YEAR-$MONTH/$RAW$YEAR$MONTH$DAY"-"$HOUR$MINUTE$SECOND"_"$HASH"."$EXT"
|
||||||
|
echo "DESTINATION: $FILE"
|
||||||
|
mkdir -p "$(dirname "$FILE")"
|
||||||
|
mv -v "$f" "$FILE"
|
||||||
fi
|
fi
|
||||||
FILE="$DESTINATIONPATH/$YEAR-$MONTH/$RAW$YEAR$MONTH$DAY"-"$HOUR$MINUTE$SECOND"_"$HASH"."$EXT"
|
|
||||||
echo "DESTINATION: $FILE"
|
|
||||||
mkdir -p "$(dirname "$FILE")"
|
|
||||||
mv -v "$f" "$FILE"
|
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$SCAN" == "TRUE" ]; then
|
if [ "$SCAN" == "TRUE" ]; then
|
||||||
echo "SCANNING..."
|
echo "SCANNING..."
|
||||||
# find "$SOURCEPATH/"* -type d -empty -delete >> /var/echo/nc-picsort.echo # nextcloud app bug when deleting folders
|
# find "$SOURCEPATH/"* -type d -empty -delete >> /var/echo/nc-picsort.echo # nextcloud app bug when deleting folders
|
||||||
chown -R www-data:www-data "$DESTINATIONPATH"
|
chown -R www-data:www-data "$DESTINATIONPATH"
|
||||||
chmod -R 777 "$DESTINATIONPATH"
|
chown -R www-data:www-data "$UNSORTABLEPATH"
|
||||||
sudo -u www-data php /opt/nextcloud/occ files:scan $USER
|
chmod -R 770 "$DESTINATIONPATH"
|
||||||
sudo -u www-data php /opt/nextcloud/occ preview:generate-all $USER
|
chmod -R 770 "$UNSORTABLEPATH"
|
||||||
|
sudo -u www-data php /opt/nextcloud/occ files:scan "$USER"
|
||||||
|
sudo -u www-data php /opt/nextcloud/occ preview:generate-all "$USER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "FINISH."
|
echo "FINISH."
|
||||||
|
|
|
@ -8,8 +8,8 @@ def systemd_timers(metadata):
|
||||||
return {
|
return {
|
||||||
'systemd-timers': {
|
'systemd-timers': {
|
||||||
f'nextcloud-picsort-{user}': {
|
f'nextcloud-picsort-{user}': {
|
||||||
'command': f'/opt/nextcloud-picsort {q(user)} {q(paths["source"])} {q(paths["destination"])}',
|
'command': f'/opt/nextcloud-picsort {q(user)} {q(paths["source"])} {q(paths["destination"])} {q(paths["unsortable"])}',
|
||||||
'when': '*:0/10',
|
'when': '*:0/30',
|
||||||
}
|
}
|
||||||
for user, paths in metadata.get('nextcloud-picsort').items()
|
for user, paths in metadata.get('nextcloud-picsort').items()
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
'ckn': {
|
'ckn': {
|
||||||
'source': 'SofortUpload/AutoSort',
|
'source': 'SofortUpload/AutoSort',
|
||||||
'destination': 'Bilder/Chronologie',
|
'destination': 'Bilder/Chronologie',
|
||||||
|
'unsortable': 'SofortUpload/Unsortable',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'vm': {
|
'vm': {
|
||||||
|
|
Loading…
Reference in a new issue