title: Batch file and variable USB drive letters
body: <p>I'm trying to create a backup batch file to automate Acronis True Image and backup maintenance.</p>
  
  <p>The USB drive letter changes depending on which machine I'm backing up and /or how many devices are connected and using drive letters...</p>
  
  <p>My batch resides in <code>C:\</code>
  My batch will call ATI.
  ATI dumps an image onto <code>C:\</code>
  The batch then looks for my external based on its volume serial number like so:</p>
  
  <pre><code>SET SN=30BC-F5A4
  SET found=
  
  0&gt;NUL SET /P=Searching for external drive...
  TIMEOUT 3 /NOBREAK &gt;NUL
  
  FOR %%N IN (D E F G H I J K L M O P Q R S T U V W X Y Z) DO (
  IF defined found CALL :MOVE
  VOL %%N: 2&gt;NUL | FIND "%sn%" &gt;NUL &amp;&amp; CALL :MOVE %%N
  )
  
  ECHO  Fail^^!
  TIMEOUT 3 /NOBREAK &gt;NUL
  
  ECHO.
  ECHO Connect it now and cancel "Autoplay".
  TIMEOUT 3 /NOBREAK &gt;NUL
  
  ECHO.
  ECHO Press any key to try again...
  PAUSE &gt;NUL
  
  CALL: EXTERNAL
  
  
  
  :: ***MOVE BACKUP***
  
  :MOVE
  </code></pre>
  
  <p>OK, that work just fine, but what I'm needing now is something along the lines of;</p>
  
  <p>Find the correct external device based off of serial number. (As above)
  Grab the correct drive letter and turn it into a variable.
  Break out of the <code>FOR IN DO</code> loop when the drive letter is found and make it a variable.
  Use variable to check if a folder exists.
  If the folder doesn't exist, create it.
  If the folder does exist, check if <code>MyBackup.tib</code> exists within.
  If so, delete the file.
  <code>CHDIR</code> or somesuch back to where the batch resides, (<code>C:\</code>) and <code>MOVE</code> the newly created backup into the folder on the external.</p>
  
  <p>I'm coming up on ten hours straight working on this issue and I'm no closer to finding the correct syntax/command(s) than I was at the start.</p>
  
  <p>PLEASE, can you help!?
  I'll give you a cookie, lol!</p>
  
  <p>I'm running Windows 7 Ultimate if that helps...</p>