nosalan / powershell-mtp-file-transfer

Powershell script to copy files/folders from the Android phone connected to Windows PC
48 stars 13 forks source link

This is a super helpful script! Thank you! #2

Open brothers-morrison opened 3 years ago

brothers-morrison commented 3 years ago

Hey I just wanted to say thanks for the great script. I've modified it slightly for my own purposes, but this is super helpful and saved me tons of time.

Thank you very much!

PS. : strangely not all files are detected on first run. I found that in the case of directories with a very large number of files in them, I had to run 10 or 20 times before all files were detected, and I'm still not sure I got everything. I used the following loop to run it a bunch of times and eventually it seemed to get all (I think?) of the files.

`1..100 |%{ .\original_phone_backup_recursive.ps1 }`

Any suggestions about getting the entire directory contents the first time?
or is this an artifact of how the connection works?

nosalan commented 3 years ago

Thanks for the feedback.

I also noticed that not all files are detected often. I suppose it can be due to $sourceMtpDir.GetFolder.Items() call not waiting for entire directory content to be loaded when the directory is mounted via MTP protocol. I think that opening the directory in windows explorer before running the script helps. But definitely it's a weird behavior and worth investigating.