Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch    |    Fun with MS-DOS batch files    |    42,547 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 41,457 of 42,547    |
|    foxidrive to All    |
|    Re: Any method of getting uuid's of unmo    |
|    01 Sep 16 21:31:41    |
   
   From: foxidrive@server.invalid   
      
   On 31/08/2016 19:07, T wrote:   
   >>   
   >> @echo off   
   >> setlocal enabledelayedexpansion   
   >> for /f %%a in ('mountvol ^|find "\"') do (   
   >> if "%%~da"=="\\" (   
   >> set "uuid=%%a"   
   >> ) else (   
   >> echo "%%a"|find "\">nul || echo !uuid!   
   >> )   
   >> )   
   >> pause   
   >   
   >   
   > Thank you!   
   >   
   > How are you testing for "NO MOUNT POINTS" and then   
   > printing the UUID from the prior line?   
      
   The term %%~da returns the drive letter of a path in the usual case and   
   when fed a UUID format that for metavariable returns \\ instead.   
      
   The if - else command saves the UUID each time it encounters a line which   
   shows that \\ in it.   
      
   When using delayed expansion a variable can be saved within a loop and then   
   accessed with the !variable! syntax instead of the %variable% syntax.   
      
      
      
   The ELSE section takes over when the line doesn't have that \\ of a UUID   
   and in this line below the script is looking for a \ character which the   
   wanted line doesn't have.   
      
   The magic is in the || and && set of operators which fire the next command   
   depending on the errorlevel of the previous command. Conditional execution.   
      
   echo "%%a"|find "\">nul || echo !uuid!   
      
      
   When the find filter doesn't detect the term it is looking for it sets the   
   errorlevel to 1. The || operator executes a command when the errorlevel   
   is not zero. Here it echos the previously saved UUID line.   
      
      
      
   For completeness sake, a zero errorlevel is generally a sign of a   
   successful operation and the && operator executes a command on an   
   errorlevel of zero.   
      
   --- 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