Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android: Recursive copy with adb push

Tags:

android

adb

I think adb's push is file-based. I want to be able to push entire folders. Is there an easy way without scripting?

Thanks!

Edit: I need to work with sub-folders.

Edit: Seems that adb pull is recursive but push is not. So I changed the title and description accordingly.

like image 537
kakyo Avatar asked Oct 30 '12 18:10

kakyo


People also ask

Does adb push overwrite?

Using adb push overwrites every existent file and thus takes ages to finish. adb sync does only push the file if it exists on the phone AND contains other data than the local version.

How to Push a file via adb?

Push a file to your Android deviceThe format starts with the command adb push, then adds the local location of the file and the location on device you want to save to. To keep it absolutely simple, let's just put that video file back on the device. Hit enter, of course, and watch your files fly.


2 Answers

Try this (worked with subfolders): adb push mySourceFolder/. myDestAndroidFolder.

Empty folders do not copy to android device.

like image 99
Yura Shinkarev Avatar answered Sep 23 '22 04:09

Yura Shinkarev


I'm gonna dig this even more to give a full solution to this (for linux only), because google redirect to this and I had this exact same problem.

With a simple adb push, the problem is that all the subdirectories must exist BEFORE doing the push, which can be very painful to achieve.

Note that an easy solution is to zip the folder, push the zip then unzip on the device. But let's say you don't have unzip on your device (highly unlikely, really).

You want to push a full tree with a lot of subdirectories to your device in an empty directory myDirectory. There are two steps :

First create all the subdirectories, in your source device:

cd <folder-containing-myDirectory> find myDirectory/ -type d -exec adb shell mkdir <path-to-folder-containing-myDirectory-in-device>/{} \; 

This command find all the subdirectories of myDirectory (including ., so if myDirectory already exists, you will have one error message you can safely ignore) and for each of them, create the matching directory on the device.

then push everything

adb push myDirectory/. <path-to-folder>/myDirectory 
like image 35
autra Avatar answered Sep 22 '22 04:09

autra