home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,485 of 68,980   
   Tom Del Rosso to Youri Ligotmi   
   Re: How to find a drive letter ?   
   29 Jan 20 21:52:21   
   
   From: fizzbintuesday@that-google-mail-domain.com   
      
   Youri Ligotmi wrote:   
   > Hi there,   
   >   
   > I'm writing a batch file to save files on a usb stick. The problem is   
   > the letter which the stick is assigned to.   
   > I know the name of the drive (fil_save), is there any solution to find   
   > the letter if the name is known (the letter may change depending on   
   > the usb drives connected before).   
      
   This works for me. You can have multiple backup drives, and this will   
   find the first one and identify its drive letter.   
      
   Set BackupDriveVOL to a list of volume serial numbers.  Or just one.   
      
   Lines of code are numbered so you know where they are wrapped.   
      
   [1]set "BackupDriveVOL=954F-4D81 054D-4F43 5035-0C6A"   
   [2]set "BackupDrive="   
   [3]for %%l in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if   
   exist %%l:\ for /f "tokens=1-5" %%a in ('vol %%l: 2^>nul') do for %%v in   
   (%BackupDriveVOL%) do if /i "%%a %%b %%c %%d %%e"=="Volume Serial Number   
   is %%v" (set "BackupDrive=%%l" & goto :endsearch)   
   [4]:endsearch   
   [5]if not defined BackupDrive goto :NObackupdrive   
   [6]echo %BackupDrive%:   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca