DEV Community

Cover image for [Video] Shell script using ADB (Android Debug Bridge) to automate a repetitive task
Benjamin Kadel
Benjamin Kadel

Posted on

4 1

[Video] Shell script using ADB (Android Debug Bridge) to automate a repetitive task

Another relatively quick video to highlight the power of writing scripts to automate boring & repetitive processes.

I explain my process when it comes to tasks, that if I have found that I have done that same task, the same way, 3 times, then I will instead find a way to automate that task! In this video I use downloading my most recently recorded video file from my phone to my computer for editing, as usually its a bit of a fiddly, clicky, boring process that I discovered a computer can do much faster than I can.

I use a command line tool called ADB, Android Debug Bridge, to achieve this... Have a look...
(More reading below the Embedded Video)...

Here is the contents of the script mentioned in the video (VidPull) that basically asks a connected Android device for the file name of the newest mp4, aka video file, that exists on the phone then it downloads it onto your machine... Easy Peesey!

#!/usr/bin/env bash
echo "Pulling newest video"
file=$(adb shell ls sdcard/DCIM/Camera | grep mp4 | tail -n1 | sed 's/^M//g')
adb pull "sdcard/DCIM/Camera/$file"
view raw vidpull hosted with ❤ by GitHub

Hopefully it all makes sense, if you want to use the script mentioned then don't forget to chmod the script so that your system can run it...

chmod +x vidpull

(where vidpull is the name of the script)

I am trying to grow my new YouTube channel too...

cough
Link: https://www.youtube.com/channel/UCMz9lmndR0BEqi70kM_ioyA
cough

So please give me as much feedback & criticism as possible so that I can improve and if you liked it or any other video that I have done please share it around, it would really help!

For any questions about ADB or even ideas for future videos please reach out on twitter https://twitter.com/ben_kadel

Thanks!

Sentry blog image

The countdown to March 31 is on.

Make the switch from app center suck less with Sentry.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs