備份Android機上的照片

來源:互聯網
上載者:User

標籤:pop   style   one   android   log   thunder   調用   .com   pre   

[本文出自天外歸雲的部落格園]

一年一度的春節放假開始了,今天收拾柜子發現了一台上大學時候用的android機,裡面有幾百張當年的回憶。

寫了個shell指令碼遍曆了下照片存放的路徑,然後用一個python指令碼把照片下載到本地。

Shell指令碼如下:

#!/bin/bash  for file in /sdcard/external_sd/DCIM/100LGDSC/*  doif [ -f "$file" ]then  echo $file  fi  done

其中“/sdcard/external_sd/DCIM/100LGDSC/*”是我android機上照片存放的路徑。

我在“adb shell ls /sdcard/external_sd/DCIM”這個路徑下存放這個指令碼:

adb shellcd /sdcard/external_sd/DCIMtouch test.sh

然後在本地寫個python指令碼調用android機上的這個shell指令碼,把遍曆結果(照片路徑)都下載到本地:

# coding:utf-8import 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(["adb","pull",line.decode().strip()])

之後在python指令碼所在目錄下執行指令碼,把照片下載到當前路徑:

 

備份Android機上的照片

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.