1

I'm looking for an approach (for Windows) to copy certain phone contents (say Downloads/ dir) automatically to a certain PC directory, after setting the USB mode to "File transfer". Theoretically it sounds not complicated - list the directories on a connected device (detect a drive) --> pick the relevant one --> copy into the predefined dir. Did someone alredy implement any similar task?

  • 1
    This is better automated using ADB shell commands because MTP sucks (it's not a drive letter). – Andy Yan Oct 23 '18 at 2:30
2

So i achieved the desired via old good Linux.

Steps: Use Mobaxterm, Cygwin or any other Linux-to-Windows framework that restructures Windows tree to a Linux one.

Once the phone is connected and it's drive set to act as USB (i.e. a drive letter is assigned, say E:), it can be defined for $DIR variable for future usage.

Then this part of Bash code can run on a platform that transfers Linux bash input to the language readable by any PC. From here Linux makes all the trick.

The code:

#!/bin/bash

DIR="/drives/"$1"/"     # SRC DIRECTORY
DEST="/drives/d/DEST/"  # DEST DIRECTORY

find "$DIR" -type f \( -iname "*.pat1" -o -iname "*.pat2" \) -exec cp '{}' "$DEST" \;  #SEARCH SRC DIR AND COPY TO DEST FILES OF MULTIPLE PATTERNS

Syntax:

./SCRIPTname.sh e       # "E" stands for the drive letter assigned to the Android device

To monitor a phone connection automatically once a 3 seconds and have timings statistics use:

watch -n 3 time ./SCRIPTname.sh e

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.