AndroidPocketablesTutorials

Using Tasker to automatically offload media to USB

Tasker USB OTGOne of the things I absolutely abhor about modern smartphones is the insistence of the manufacturers to sacrifice expandability for the sake of thinness. Case in point: the HTC One, which has sacrificed the ability to add an SDHC, and limits the phone to whatever storage you purchased. Unfortunately, HTC isn’t the only smartphone manufacturer that feels you don’t need the ability to swap out storage media.

I wrote a piece recently on how to survive an expansion-less device, and I mentioned I produce a lot of high resolution content from the phones I use on a daily basis. I believe HTC and the like are reducing the options to expand storage due to the great availability of network storage options such as Dropbox, Google+ photo backup, Facebook, and others that allow you to delete the photos on your phone and grab them later if you’re in a pinch for storage.

Unfortunately, if you’re out taking wilderness photos and videos with your now off-network cell phone, Dropbox isn’t going to help you. And with no ability to swap SD cards, your options are either to go back to camp and copy off to a computer you dragged along on your wilderness adventure, or the one I’m going to discuss here: using Tasker to offload media to a USB thumb stick via a USB OTG cable.

Parts required

You’ll need a USB OTG cable, a USB thumb drive, and a device that supports USB OTG. If you’re not certain whether or not your device does, you can get an app from Google Play that checks to see if your kernel supports USB OTG, or just spend a couple of bucks on a cable and hope for the best.

For purposes of determining locations that the files need to come from and go to, you’ll probably want some sort of wireless ADB application if your ROM doesn’t natively support that. I used ADB Konnect, but it doesn’t matter. You can also use a terminal emulator if you’re comfortable poking around via the device, or you can use a file manager if you’re more comfortable with that.

Determining mountpoints

On my HTC, the internal storage for photographs and videos is located in /sdcard/DCIM/100MEDIA/. You may need to poke around your system to locate the right folder as various ROMs use different directories, but they’re generally all going to be underneath a folder called DCIM.

I used a program called ES File Explorer to locate my USB stick when plugged in, which was /storage/usb/; however, I’ve read of some odd systems mounting a USB OTG stick under /mnt/, so your mountpoint may vary.

Setting up the task

You’ll want to set up a state profile with USB Connected Mass Storage. After that it’s a relatively simple copy and delete operation.

For the task, I’m only suggesting the copy command here during testing with a manual delete of the photos and videos, as I’d hate to accidentally wipe out your photos. For purposes of this task, I had it flash a message that the USB was seen, and then execute the shell command to copy the photos in the DCIM directory off to the USB stick.

The full shell command is cp /sdcard/DCIM/100MEDIA/*.jpg /storage/usb/sync/, with “sync” being a directory I created on the USB stick that will contain the photos.

Upon plugging in a USB OTG cable and USB stick, the task should run and copy off all photos to the USB drive.

Notes for modifications

My initial plan was to create a shell script containing a copy command followed by a loop to verify that the contents of the source folder now existed on the USB stick, and then remove them one by one from the internal storage as they’re verified.

It’s not particularly difficult to script, but if something is wrong, I’d rather not be to blame.

Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Paul E King

Paul King started with GoodAndEVO in 2011, which merged with Pocketables, and as of 2018 he's evidently the owner. He lives in Nashville, works at a film production company, is married with two kids. Facebook | Twitter | Donate | More posts by Paul | Subscribe to Paul's posts

Avatar of Paul E King