Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a non-optimal solution. In this case, the UFD has to have a specific name, which is passed to the script which searches every possible drive letter for a match. It's probably not practical to rely on the flash drives all having the same name.</p> <p>Still hoping someone pops by with a better answer!</p> <pre><code>setlocal :: Initial variables set TMPFILE=%~dp0getdrive.tmp set driveletters=abcdefghijklmnopqrstuvwxyz set MatchLabel_res= for /L %%g in (2,1,25) do call :MatchLabel %%g %* if not "%MatchLabel_res%"=="" echo %MatchLabel_res% goto :END :: Function to match a label with a drive letter. :: :: The first parameter is an integer from 1..26 that needs to be :: converted in a letter. It is easier looping on a number :: than looping on letters. :: :: The second parameter is the volume name passed-on to the script :MatchLabel :: result already found, just do nothing :: (necessary because there is no break for for loops) if not "%MatchLabel_res%"=="" goto :eof :: get the proper drive letter call set dl=%%driveletters:~%1,1%% :: strip-off the " in the volume name to be able to add them again further set volname=%2 set volname=%volname:"=% :: get the volume information on that disk vol %dl%: &gt; "%TMPFILE%" 2&gt;&amp;1 :: Drive/Volume does not exist, just quit if not "%ERRORLEVEL%"=="0" goto :eof set found=0 for /F "usebackq tokens=3 delims=:" %%g in (`find /C /I "%volname%" "%TMPFILE%"`) do set found=%%g :: trick to stip any whitespaces set /A found=%found% + 0 if not "%found%"=="0" set MatchLabel_res=%dl%: goto :eof :END if exist "%TMPFILE%" del "%TMPFILE%" endlocal </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload