title: how to change variable value inside loop in batch
body: <p>I use the below code in order to create a directory from the value of the first 4 chars of collector text file</p>
  
  <pre><code>@echo off &amp; setlocal enabledelayedexpansion
  
  :loop
  
  set /P txt_file=&lt;Collector.txt
  Set collector_id=!txt_file:~0,4!
  
  :: check for existence of [OutputFolder]
  :: if [OutputFolder] doesn't exist, create it
  if not exist %collector_id% (
    echo folder %collector_id% not found
    echo creating folder %collector_id%
    md %collector_id% 
    )
  
  xcopy *.txt %collector_id% /v 
  Del *.txt
  
  goto loop
  </code></pre>
  
  <p>I want to execute the above loop continuously in order to check if current directory is empty or not. If not I want to make a dir, if does not exist, with name the first 4 chars of collector.txt.</p>
  
  <p>If the directory is not empty everything is ok. When the above is looping and I add collector.txt to the current directory the collector_id does not change. </p>
  
  <p>Where am I wrong?  </p>
  
  <p>Is there any other way, expect infinite, loop to do this?</p>