0

Goal: I want to automate copying files (JPG and \ or CR2) from multiple SD \ CF cards into my files into my photo storage system.

Problem: I'm more comfortable in Bash than Powershell but WSL2 doesn't yet support USB drives easily.

Question: How can I check if one or more SD \ CF cards are plugged in and check if certain folders are present? In this case, [drive]:\DCIM\100CANON. I've found this question but I can't quite get it working. Ideally, I want to be able to store the output inside a variable that I can then loop through (and run said copy routine)

Alistair Hardy
  • 397
  • 1
  • 4
  • 16

1 Answers1

1

The .Net namespaces...

Get-WMiObject -Class Win32_Volume | Select Name, DriveLetter, Caption, Label, DevideID, DriveType, Capacity

or

Get-CimInstance -ClassName Win32_Volume | Select Name, DriveLetter, Caption, Label, DevideID, DriveType, Capacity

or use the Win32_DiskDrive, Win32_DiskDrivePhysicalMedia, and use the Model property value.

Partitions : 1
DeviceID   : \\.\PHYSICALDRIVE6
Model      : SDHC Card
Size       : 3964584960
Caption    : SDHC Card

... and the Get-PSDrive ...

Get-PSDriive

Or

Get-PSDrive -PSProvider FileSystem

# Results
<#
Name           Used (GB)     Free (GB) Provider      Root
----           ---------     --------- --------      ----
A                                                    A:\
C                 202.06      23718.91 FileSystem    C:\
D                1211.06     123642.32 FileSystem    D:\
G                 202.06        710.91 FileSystem    \\Music\GratefulDead
#>

... cmdlet will list all connected drives as shown.

Filtering drives are documented here:

Filtering get-psdrive to all Local Drives

DriveType is a property of the Win32_Volume structure which enumerates the type of drive. The value 3 stands for Local Disk. Below is the full list of values.

0 - Unknown

1 - No Root Directory

2 - Removable Disk

3 - Local Disk

4 - Network Drive

5 - Compact Disk

6 - RAM Disk

Note, that there is no property/option specifically for SD or CF.

So, for your use case, if your SD/CF has root labeled similar to the above, then you can get to them using the Root property value or use the drive size as your target, since in normal cases, your camera/phone, etc storage media would always be below 32GB total maximum size.

postanote
  • 15,138
  • 2
  • 14
  • 25