Programming Details - RalfDetzler/media-importer GitHub Wiki
Access to Smartphones via USB
When smartphones are connected via USB, they appear in Windows Explorer. There you can navigate through the folders and copy files in both directions. But when you try to access these folders from command line or from any programming language with standard file and directory routines, you will most probably fail.
The smartphones provide their content as MTP device. The Windows Explorer has an integration of MTP protocol and provides access to these devices, similar as to local disk content with folders and files. For some programming languages as python, nodejs, java there are some libraries available to access MTP devices. But it is a hurdle to get them running in different Windows versions - they often are outdated and not working with current Windows.
The only stable environment I found, is to use the COM automation of Windows Explorer. And this can be easily used in PowerShell.
List MTD Devices
$folder = (new-object -com shell.application).NameSpace(0x11)
$items = $folder.Items()
for ($i= 0; $i -lt $items.Count; $i++) {
write-output ($items.Item($i).Name)
}