簡體   English   中英

如何使用 Windows 上的 Powershell 將多個文件推入/拉出 Android 和 ADB?

[英]How to push/pull multiple files to/from Android with ADB using Powershell on Windows?

我需要專門使用 Windows 10 Powershell,而不是 gitbash 或 cygwin 或 CMD,因為 SO 上的其他答案已提供。 我需要能夠使用通配符。 我需要能夠使用通配符從 Windows 到 Android 推送到特定文件夾(不是整個文件夾,因為 SO 上的其他答案已經提供)。

Ex: adb push *.png /sdcard/Android/data/myapp/files
Ex: adb pull /sdcard/Android/data/myapp/files/h*.txt

抱歉,如果這個問題已經得到解答,我還沒有找到這個具體的答案。

您可以利用 powershell 中的循環為每個文件分別調用 adb 命令。 獲取您想要推送或拉取的文件,循環並為每個文件調用 adb。

$adb = 'C:\temp\platform-tools\adb.exe'
$local = 'C:\temp\testfiles'
$remote = '/sdcard/Android/data/myapp/files'

function push-adbfiles {
    param ()
    # use Get-ChildItem to capture which files to push
    $files = Get-ChildItem -file $local\*.png

    # loop using ForEach-Object and call adb push command for each
    $files | ForEach-Object {
        & $adb push $_ $remote 
    } 
}


function pull-adbfiles {
    param ()
    # use nix find command to find and return full path of matching files
    $files = & $adb shell find "$remote/h*"

    # loop through files running adb pull on each
    $files | ForEach-Object {
        & $adb pull $_ $local
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM