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,484 of 68,980   
   JJ to Youri Ligotmi   
   Re: How to find a drive letter ?   
   29 Jan 20 19:47:53   
   
   From: jj4public@vfemail.net   
      
   On Tue, 28 Jan 2020 13:32:53 +0100, 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).   
   > Thanks in advance   
   >   
   > YL   
      
   Use this.   
      
     @echo off   
     setlocal   
     set cl=wmic logicaldisk where "volumename='fil_save'" get caption   
     set drive=   
     for /f %%A in ('%cl%') do (   
       if not "%%A" == "" set drive=%%A   
     )   
     if "%drive%" == "" (   
       echo Drive not found.   
       goto :eof   
     )   
     echo Drive found: %drive%   
      
   --- 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