[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