Browse Source

Add mtime script

master
Pekka Helenius 1 year ago
parent
commit
8cc41b959e
2 changed files with 41 additions and 1 deletions
  1. +6
    -1
      3_desktop_files_for_kde-plasma-dolphin/02_imagetools-dng-cr2.desktop
  2. +35
    -0
      4_scripts/imagetools_09_mtime.sh

+ 6
- 1
3_desktop_files_for_kde-plasma-dolphin/02_imagetools-dng-cr2.desktop View File

@ -3,7 +3,7 @@ Type=Service
ServiceTypes=KonqPopupMenu/Plugin
Icon=application-x-theme
MimeType=image/x-canon-cr2;image/x-adobe-dng;
Actions=convert_dualiso;raw_tags;
Actions=convert_dualiso;raw_tags;correct_mtime;
X-KDE-StartupNotify=false
X-KDE-Priority=TopLevel
X-KDE-Submenu=Image Tools
@ -17,3 +17,8 @@ Exec=/usr/share/kservices5/ServiceMenus/imagetools_02_dualiso.sh %F
Name=Rename, Uncrop & Add Baseline Tags
Icon=application-x-theme
Exec=/usr/share/kservices5/ServiceMenus/imagetools_03_raw_resolution-baseline.sh %F
[Desktop Action correct_mtime]
Name=Set mtime to DateTimeOriginal
Icon=application-x-theme
Exec=/usr/share/kservices5/ServiceMenus/imagetools_09_mtime.sh %F

+ 35
- 0
4_scripts/imagetools_09_mtime.sh View File

@ -0,0 +1,35 @@
#!/bin/bash
################################################################################################
# File system check
# We don't allow writing to SD card.
#Sed is here to remove any trailing spaces and crap like blank lines
INPUT_FILESYSTEM=$(df -h "${1}" | awk -F ' ' 'FNR> 1 {print $1}' | grep -i -E "/dev/sd?|/dev/hd?|?rewritefs|?tmpfs|/dev/nvme?" | sed '/^\s*$/d' | wc -l)
if [[ "${INPUT_FILESYSTEM}" -eq 0 ]]; then #if input file (first file printed in bash) filesystem does not start with /dev/sdX
kdialog --error "Image(s) are in a SD Card. Please move them your local or external storage and try again."
exit
fi
################################################################################################
#We get the directory just from the first filename. Pwd should be easier, but bugged, so...
INPUT_DIR=$(dirname "${1}")
DIR_BASENAME=$(echo "${INPUT_DIR}" | rev | cut -d/ -f 1 | rev)
while [[ $# -gt 0 ]]; do
################################################################
# Values that change during the while loop (differ from file to file)
INPUT="${1}"
MTIME=$(exiftool -d "%s" -DateTimeOriginal -s -S "${INPUT}")
touch --date=@${MTIME} "${INPUT}"
shift # Move to the next file
done

Loading…
Cancel
Save