How to automatically copy contents from the connected phone 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?
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