How to discover the newly assigned USB drive letter?

Started by Dariusz Piatkowski, May 14, 2025, 05:50:11 AM

Previous topic - Next topic

Dariusz Piatkowski

I'm using a little nifty REXX script to download pics off of my DSLR's memory card:

- issue the LVM rediscover attached media with '@LVM.EXE /RediscoverPRM'
- if no errors encountered start doing the copy

My problem is that when I created that script I never attempted to figure out what that removable media assigned drive letter is...it was simpler to just use a static name (used to be drive 'W:' and assigned to the disk with LVM) and run with it.

Well, recently I added a few NAS shares to my NetDrive and happened to map this to the drive letter which was previously assigned to the USB storage media card. Now my script doesn't work b/c that old drive letter is no longer usable and the USB stuff is assigned 'D:' instead.

OK, seems simple, but where the heck do I even start with querrying this in REXX?

I took a stab at this by reading through Alex Taylor's "RxLVM Library Reference - Version 0.5.1 - March 18, 2007", but that's really about all sorts of disk functions, so not what I'm looking for.

Any other references I could look up for this functionality?

Thanks!

Dave Yeo

Use LVM to change the cards drive letter? Pick a high one and probably won't need to change it again.
Otherwise you'll have to figure out how to query LVM.

Neil Waldhauer

x = SysDriveMap()
externalDiskLetter = ''
do while x <> ''
   parse var x this x
   i = SysDriveInfo(this)
   parse var i letter free total label
   if strip(label) = 'Blue 2TB' | strip(label) = 'Red 2TB' then do
      externalDiskLetter = strip(letter)
   end
end
Expert consulting for ArcaOS, OS/2 and eComStation
http://www.blondeguy.com

Jan-Erik Lärka

One of the new functions in the REXXUTIL.DLL from Object-Oriented REXX may also help you:

SysFileSystemType
get the name of the file system for a drive

Example

  cfs = SysFileSystemType('C:')
  efs = SysFileSystemType('E:')
  SAY 'The file system on drive C: is' cfs
  SAY 'The file system on drive E: is' efs

The following is a sample of output from this example:

  The file system on drive C: is HPFS
  The file system on drive E: is JFS

Rich Walsh

No need to get fancy here...

SysDriveMap() before calling LVM.
SysDriveMap() after calling LVM.
What changed?

Jan-Erik Lärka

Quote from: Rich Walsh on May 15, 2025, 04:14:37 AM
No need to get fancy here...

SysDriveMap() before calling LVM.
SysDriveMap() after calling LVM.
What changed?

something like:

/* Comment */
...
before = SysDriveMap()
'@LVM.EXE /RediscoverPRM'
after = SysDriveMap()
DO i = 1 TO WORDS( after )
  IF 0 = POS( SUBWORD( after, i, 1 ), before )  THEN
    SAY SUBWORD( after, i, 1 ) "must be the drive we're looking for!"
END


Nice!