OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Storage => Topic started by: Dariusz Piatkowski on May 14, 2025, 05:50:11 am

Title: How to discover the newly assigned USB drive letter?
Post by: Dariusz Piatkowski on May 14, 2025, 05:50:11 am
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!
Title: Re: How to discover the newly assigned USB drive letter?
Post by: Dave Yeo on May 14, 2025, 06:56:43 am
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.
Title: Re: How to discover the newly assigned USB drive letter?
Post by: Neil Waldhauer on May 14, 2025, 03:25:31 pm
Code: [Select]
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
Title: Re: How to discover the newly assigned USB drive letter?
Post by: Jan-Erik Lärka on May 14, 2025, 08:37:31 pm
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
Title: Re: How to discover the newly assigned USB drive letter?
Post by: 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?
Title: Re: How to discover the newly assigned USB drive letter?
Post by: Jan-Erik Lärka on May 15, 2025, 10:04:40 pm
No need to get fancy here...

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

something like:

Code: [Select]
/* 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!