diff --git a/bash/file_management/README.md b/bash/file_management/README.md new file mode 100644 index 00000000..4c9fdc94 --- /dev/null +++ b/bash/file_management/README.md @@ -0,0 +1,17 @@ +# Install file management + +inspired by the work of Karl Voit +https://karl-voit.at/managing-digital-photographs/ + +install all these scripts to use geeqie and Novoid libs to manage your files. +check the install script to ensure it makes what you expect from it before running it. +``` bash +bash install.sh +``` +# tldrlol +install all the things with this: +``` bash +git clone https://forge.chapril.org/tykayn/scripts +cd scripts/bash/file_management +bash install.sh +``` diff --git a/bash/file_management/add-tags.desktop b/bash/file_management/add-tags.desktop new file mode 100644 index 00000000..f192c3a1 --- /dev/null +++ b/bash/file_management/add-tags.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=filetags add +GenericName=filetags +Comment= +Exec=$HOME/areas/www/misc/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; diff --git a/bash/file_management/append-name.desktop b/bash/file_management/append-name.desktop new file mode 100644 index 00000000..6ac91d9c --- /dev/null +++ b/bash/file_management/append-name.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=filetags append file name +GenericName=filetags +Comment= +Exec=$HOME/areas/www/misc/vk-filetags-interactive-append-file-name-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; diff --git a/bash/file_management/guess-filename.desktop b/bash/file_management/guess-filename.desktop new file mode 100644 index 00000000..a64b1f94 --- /dev/null +++ b/bash/file_management/guess-filename.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=filetags guess file name +GenericName=filetags +Comment= +Exec=$HOME/areas/www/misc/vk-filetags-interactive-guess-filename-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; diff --git a/bash/file_management/guess_filename.sh b/bash/file_management/guess_filename.sh new file mode 100644 index 00000000..f72ab7cd --- /dev/null +++ b/bash/file_management/guess_filename.sh @@ -0,0 +1,90 @@ +#! /bin/bash +shopt -s globstar || exit +for PIC in ** +do +# look only for jpg +if [[ "$PIC" =~ \.JPG$ ]] || [[ "$PIC" =~ \.jpg$ ]]; then + echo "file_$PIC" + # get the date and time from the tag DateTimeOriginal + DATE=$(exiftool -p '$DateTimeOriginal' "$PIC" | sed 's/[: ]//g') + LONGDATE=$(echo $DATE | sed -e 's/^\(.\{12\}\).*/\1/') + # check if DateTimeOriginal is 0000... OR empty + if [[ "$LONGDATE" != "000000000000" ]] && [[ -n "$LONGDATE" ]]; then + echo "datetimeoriginal_$LONGDATE" + # modify the attribute date with the info in the tag date + touch -t $LONGDATE "$PIC" + # customize date, in this case eliminate the time, getting only the date in 8 numbers and adding _ + DATEMOD2=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/') + echo "datemod2_$DATEMOD2" + # skip renaming if + # 8 numbers at beginning followed by _ or after IMG_ or P_ and followed by _ (already date stamped) + if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then + : + else + # this will be done + + filename=$(basename "$PIC") + echo "$filename" + echo "mv -i \""$PIC"\" \""$(dirname "$PIC")"/"$DATEMOD2""$filename"\"" + #uncomment if you like it + mv -i "$PIC" "$(dirname "$PIC")/$DATEMOD2$filename" + + fi + else + # get the date and time from the tag HistoryWhen + + DATE=$(exiftool -p '$HistoryWhen' "$PIC" | sed 's/[: ]//g') + LONGDATE=$(echo $DATE | sed -e 's/^\(.\{12\}\).*/\1/') + + # check if Historywhen is 0000... or empty + if [[ "$LONGDATE" != "000000000000" ]] && [[ -n "$LONGDATE" ]]; then + echo "historywhentag_$LONGDATE" + + touch -t $LONGDATE "$PIC" + DATEMOD2B=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/') + echo "datemod2B_$DATEMOD2B" + + if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then + : + else + # this will be done + filename=$(basename "$PIC") + echo "$filename" + echo "mv -i \""$PIC"\" \""$(dirname "$PIC")"/"$DATEMOD2B""$filename"\"" + #uncomment if you like it + mv -i "$PIC" "$(dirname "$PIC")/$DATEMOD2B$filename" + fi + + else + # get the date and time from the tag tag filemodifydate + + DATE=$(exiftool -p '$filemodifydate' "$PIC" | sed 's/[: ]//g') + LONGDATE=$(echo $DATE | sed -e 's/^\(.\{12\}\).*/\1/') + + # check if filemodifydate is 0000... or empty + if [[ "$LONGDATE" != "000000000000" ]] && [[ -n "$LONGDATE" ]]; then + #echo "filemodifydatetag_$LONGDATE" + + #touch -t $LONGDATE "$PIC" + DATEMOD2C=$(echo $DATE | sed -e 's/^\(.\{8\}\).*/\1_/') + echo "datemod2C_$DATEMOD2C" + + if [[ "$PIC" =~ [[:digit:]]{8}_.*$ ]] || [[ "$PIC" =~ IMG_[[:digit:]]{8}_.*$] ]] || [[ "$PIC" =~ P_[[:digit:]]{8}_.*$] ]]; then + : + else + # this will be done + filename=$(basename "$PIC") + echo "$filename" + echo "mv -i \""$PIC"\" \""$(dirname "$PIC")"/"$DATEMOD2C""$filename"\"" + #uncomment if you like it + mv -i "$PIC" "$(dirname "$PIC")/$DATEMOD2C$filename" + fi + + else + + echo "Error, NO date available" + fi + fi + fi +fi +done diff --git a/bash/file_management/install.sh b/bash/file_management/install.sh new file mode 100644 index 00000000..60971fc5 --- /dev/null +++ b/bash/file_management/install.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +echo "installation des outils de file management pour geequie" + + +if ! hash "exiftool" > /dev/null; then + echo "installer les paquets apt: apt install exiftool xfce4-terminal geeqie " + apt install exiftool xfce4-terminal geeqie gnome-terminal + +fi + +if ! hash "guessfilename" > /dev/null; then + echo "installer les paquets python : guessfilename filetags date2name appendfilename" + pip install guessfilename filetags date2name appendfilename + +fi + + +# créer le dossier de scripts +if [ ! -d $HOME/areas/www/misc ]; then + echo "installer les dossiers PARA dans la home" + mkdir -p $HOME/areas/www/misc + mkdir -p $HOME/projects + mkdir -p $HOME/archives + mkdir -p $HOME/ressources +fi + + +if [ ! -d $HOME/areas/www/misc/novoid/filetags ]; then + git clone https://github.com/novoid/filetags.git $HOME/areas/www/misc/novoid +fi + + + +mkdir -p $HOME/.config/geeqie/applications + +# copier les wrappers +echo "copier les wrappers dans $HOME/areas/www/misc" +cp vk-filetags*.sh $HOME/areas/www/misc + +cp guess_filename.sh $HOME/areas/www/misc +cp vkorgheadingstats.sh $HOME/areas/www/misc +# rendre éxécutable les scripts +chmod u+x /home/cipherbliss/areas/www/misc/*.sh + +# copier les scripts qui seront utilisés par geeqie +echo "copier les scripts qui seront utilisés par geeqie dans $HOME/.config/geeqie/applications/" +cp *.desktop $HOME/.config/geeqie/applications/ + +echo "ça c'est fait. plus qu'a configurer les raccourcis de ces scripts dans la partie plugins de Geeqie" diff --git a/bash/file_management/remove-tags.desktop b/bash/file_management/remove-tags.desktop new file mode 100644 index 00000000..f64ffb7d --- /dev/null +++ b/bash/file_management/remove-tags.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Name=filetags remove +GenericName=filetags +Comment= +Exec=$HOME/areas/www/misc/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh %F +Icon= +Terminal=true +Type=Application +Categories=Application;Graphics; +hidden=false +MimeType=image/*;video/*;image/mpo;image/thm +Categories=X-Geeqie; diff --git a/bash/file_management/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh b/bash/file_management/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh new file mode 100644 index 00000000..2ed46cca --- /dev/null +++ b/bash/file_management/vk-filetags-interactive-adding-wrapper-with-gnome-terminal.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=73x5+330+5 \ + --hide-menubar \ + -x $HOME/areas/www/misc/novoid/filetags/__init__.py --interactive "${@}" + +#end diff --git a/bash/file_management/vk-filetags-interactive-append-file-name-wrapper-with-gnome-terminal.sh b/bash/file_management/vk-filetags-interactive-append-file-name-wrapper-with-gnome-terminal.sh new file mode 100644 index 00000000..3517a1a7 --- /dev/null +++ b/bash/file_management/vk-filetags-interactive-append-file-name-wrapper-with-gnome-terminal.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=73x5+330+5 \ + --hide-menubar \ + -x $HOME/.local/bin/appendfilename "${@}" + +#end diff --git a/bash/file_management/vk-filetags-interactive-guess-filename-with-gnome-terminal.sh b/bash/file_management/vk-filetags-interactive-guess-filename-with-gnome-terminal.sh new file mode 100644 index 00000000..fe8056a7 --- /dev/null +++ b/bash/file_management/vk-filetags-interactive-guess-filename-with-gnome-terminal.sh @@ -0,0 +1,8 @@ + #!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=73x5+330+5 \ + --hide-menubar \ + -x $HOME/.local/bin/guessfilename --interactive "${@}" + +#end diff --git a/bash/file_management/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh b/bash/file_management/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh new file mode 100644 index 00000000..61693ac9 --- /dev/null +++ b/bash/file_management/vk-filetags-interactive-removing-wrapper-with-gnome-terminal.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +/usr/bin/gnome-terminal \ + --geometry=73x5+330+5 \ + --hide-menubar \ + -x $HOME/areas/www/misc/novoid/filetags/__init__.py --interactive --remove "${@}" + +#end