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!

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more