Back up the photos on the Android machine

Source: Internet
Author: User

[This article is from the Sky Cloud-owned blog Park]

The annual spring Festival holiday began, today to clean up the cabinet found a stage in college with the Android machine, there are hundreds of memories of the year.

Wrote a shell script that traversed the path where the photos were stored, and then downloaded the photos locally using a Python script.

The shell script is as follows:

#!/bin/bash  forfile in/SDCARD/EXTERNAL_SD/DCIM/100LGDSC/*   Doif [-F "$file"]then  echo  $file  fi Done

where "/SDCARD/EXTERNAL_SD/DCIM/100LGDSC/*" is the path to the photos stored on my Android computer.

I'm storing this script under the "adb Shell Ls/sdcard/external_sd/dcim" path:

/sdcard/external_sd/DCIMtouch test. SH

Then write a Python script locally to invoke the shell script on the Android, and download the traversal results (photo path) to Local:

 #   Coding:utf-8  import   Subprocesscmd  = "  ADB Shell sh/sdcard/external_sd/dcim/test.sh   " p  = subprocess. Popen (cmd, Shell=true,stdout=subprocess. PIPE) out  = P.stdout.readlines ()  for  line in   Out:subprocess.run ([ Span style= "color: #800000;" > " adb  " ,  pull  " , Line.decode (). Strip ()] )

Then execute the script in the same directory as the Python script and download the photo to the current path:

Back up the photos on the Android machine

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.