title: Windows batch variable in for-loop
body: <p>I created a quick batch file to check on valheim server and do backup of the save as it's not in the server folder, but i want to make it easier with variables.</p>
  <p>would like to set a variable here
  <code>for %%a in (C:\Users\Administrator\AppData\LocalLow\IronGate\Valheim\worlds\Dedicated.db)</code></p>
  <p>eg <code>for %%a in (%%valserverdb\Dedicated.db)</code></p>
  <p>How can this can be done?</p>
  <pre><code>@echo off
  :loop
  tasklist /FI &quot;IMAGENAME eq valheim_server.exe&quot; 2&gt;NUL | find /I /N &quot;valheim_server.exe&quot;&gt;NUL
  if &quot;%ERRORLEVEL%&quot;==&quot;0&quot; echo Valheim Server is running
  if &quot;%ERRORLEVEL%&quot;==&quot;1&quot; echo Valheim Server is not running starting it. | E:\gameservers\valheim\start_headless_server.bat
  
  SET valserverdb=C:\Users\Administrator\AppData\LocalLow\IronGate\Valheim\worlds
  SET valbackup=E:\gameservers\backup\IronGate\Valheim\worlds
  
  for %%a in (C:\Users\Administrator\AppData\LocalLow\IronGate\Valheim\worlds\Dedicated.db) do set valserverdbcheck=%%~ta
  
  for %%b in (E:\gameservers\backup\IronGate\Valheim\worlds\Dedicated.db) do set valbackupcheck=%%~tb
  
  if &quot;%valserverdbcheck%&quot; gtr &quot;%valbackupcheck%&quot; (xcopy &quot;%valserverdb%&quot; &quot;%valbackup%&quot; /S /E /Y) else (@echo File has not been changed. skipping)
  
  timeout /t 300 /nobreak &gt; NUL
  goto loop
  </code></pre>