Is there a way for Termux to automaticaly run exiftool every time I take a picture from phone Camera?

I installed exiftool on Termux like mentioned in this post: https://www.reddit.com/r/fossdroid/comments/j7cxhy/use_exiftool_in_termux_to_easily_remove_exif_data/

But the thing is that I forget to run the command every time I take a picture from my camera, and when I do run it like a couple days later, the date on the processed photos in the gallery says the photos were taken on the day they were processed. Is there a way to autorun the exiftool command whenever I take a picture or am I stuck with wrong dates for my photos in the gallery?

8 comments · 87% upvoted · other discussions

comments

StarGeekSpaceNerd

the date on the processed photos in the gallery says the photos were taken on the day they were processed

This sounds like the file system time stamp is read, not the embedded data. Try adding the -P (-preserve) option to your command.

To fix the already processed files, you might try copying the embedded time stamp to the file system one. exiftool '-FileModifyDate<DateTimeOriginal' /path/to/files/

sylirre

Try watchexec package.

watchexec --shell bash -w /sdcard/DCIM/Camera -- 'for i in ${WATCHEXEC_CREATED_PATH//:/ }; do exiftool YOUR_OPTIONS "/sdcard/DCIM/Camera/$i"; done'

If you do not want to stuck with wrong dates, then don't strip metadata entries DateTimeOriginal, CreateDate and ModifyDate, which one is present.

[deleted]

It doesn't work, I get an error on Termux saying Error: File not found - YOUR_OPTIONS ======== /sdcard/DCIM/Camera/20230423_051009.jpg Followed by the image's details and at the end 1 image files read 1 files could not be read [[Command exited with 1]]

sylirre

Works for me.

You seem to have exiftool error.

[deleted]

Is your phone rooted? My phone isn't rooted if it has anything to do with it. It runs well when I manually enter the exiftool command though.

sylirre

My phone is not rooted and the command doesn't expect device to be rooted or has custom ROM installed.

Make sure you didn't copy-pasted the command exactly as it written. The YOUR_OPTIONS should be replaced with actual options you supply to exiftool, this is just a place holder. Otherwise you will always get "1 files could not be read".

[deleted]

oh yeah, I set the exiftool command wrong as there was a typo, it's fixed now. I also wanted to ask, is Termux:Boot plugin needed for it to work when I restart my phone?

*edit:yeah I found out I need Termux:Boot installed for it to work when I restart my phone, however it takes a few minutes to activate after I restart my phone, so if I take a photo as soon as I restarted my phone it won't be processed, but hopefully I don't usually do that.

*edit2:I just tested restarting my phone, and sometimes it takes like 15 minutes to start

Karraspi

I am using inotifywait https://linux.die.net/man/1/inotifywait very successfully - it is a Linux native tool to watch the file system in all possible different ways! Works pretty fine with Termux as well.

Each photo shot is immediately uploaded to my private server, triggered by inotifywait - just an example!

Root not needed!

Have Fun - BR