6

I apologize if this is a duplicate, I can't find anything up-to-date that really helps answer my question.

I know this is nitpicky, but it's been a long battle and I am losing it.

For some time, I have been annoyed with the fact that you can't customize the android camera app's naming convention. My workaround, since the dawn of Dropbox camera upload, has been to use dropbox to upload and rename my photos (yyyy-mm-dd HH.nn.ss.jpg) and then use dropsync to overwrite the original file in my camera photo.

The problem I'm facing at the moment is that the camera in the hangouts app does not follow the same rules as the default camera app for my phone (Sony Xperia z3) so I end up with duplicates in my gallery of any image I happened to capture using hangouts instead of the camera. I could use the camera to take a picture and then share it using hangouts, but I decided instead to play around with Tasker and try to automate consolidating my images. (Another gripe I have is that Dropbox won't let me exclude folders, so I'd like to get rid of Camera Upload altogether and not have every screenshot I've ever taken backed up forever).

The directory for the default camera is [internal storage]/DCIM/100ANDRO and for hangouts it is [internal storage]/DCIM/Camera

I have a profile (below) triggered by the "file modified" event that will move the new file in the "Camera" folder into the "DCIM" folder. However, there is often a race condition, so Dropbox will upload the image before it is moved and again after. So my problem of duplicate images is not yet solved.

tasker profile to move newly created image
(click for larger version)

I'd like to forgo the Dropbox/Dropsync combo and instead use Tasker to rename a file as it is added to either of the camera folders. I'd like to use the same naming convention that Dropbox uses, but I can't figure out how Tasker can access the EXIF data from the image to rename the photo to something like "2014-12-30 10.23.56.jpg".

So, as a tl;dr: I am using Tasker to move images captured from different apps into a common folder. Can anyone help me add a step to rename the file I am moving based on the date and time the image was captured?

0

2 Answers 2

0

Since you are using the "file modified" trigger (which should be instant at the moment the file is written,) you can use the current date and time instead of trying to extract the EXIF data from the images.

Tasker's getFormattedDate function will help with parsing the date/time and constructing the new file name. The only issue you might have is if the source folder contains more than one image. You can use a counter variable within your loop and append it to the end of the file name to mitigate that.

2

Use Tasker's native Java calls

Java code

Use ExifInterface.getAttribute to solve this problem.

exif = new ExifInterface( %filename )
%datetime = exif.getAttribute(exif.TAG_DATETIME)

Implementation overview

  1. Getting path of a .JPG from %filename Tasker variable
  2. Construct a new ExifInterface class instance into exif Java variable
  3. Get date & time by exif.getAttribute Java function, and store results into %datetime Tasker variable
  4. Free exif Java variable
  5. Check %datetime is set (this is not set when .JPG is not contains EXIF info)

Step by step solution in Tasker

  1. Add a new Code > Java Function action

    a. Set ExifInterface to Class Or Object (or select by magnifying glass button)

    b. Write new \\ {ExifInterface} (String) to Function (or select by magnifying glass button)

    c. Write %filename to Param (String)

    d. Write exif to Return {ExifInterface}

  2. Add a new Code > Java Function action

    a. Write exif to Class Or Object (or select by coffee button)

    b. Write getAttribute \\ {String} (String) to Function (or select by magnifying glass button)

    c. Write exif.TAG_DATETIME to Param (String)

    d. Write %datetime to Return {String}

  3. Add a new Code > Java Object action

    a. Left Mode on Delete

    b. and write exif to Name

  4. Check %datetime is set - I added a conditional Flash for show %datetime

Done!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .