title: Batch script to create a folder structure with user input
body: <p>We are re doing a folder structure on our main server for storage.  But we want to simplify the process as much as possible for the graphics design team that's going to use it.  So I am writing a bunch of scripts and this specific script needs to create a new folder for the year specified, rename the previous years fold and the the oldest year folder needs to be moved to Archive &amp; renamed.
  <a href="https://i.stack.imgur.com/pmw7q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pmw7q.png" alt="Folder Structure"></a></p>
  
  <pre><code>@ECHO OFF
  
  SET /P nyear=Enter Year:
  SET /A myear =%nyear%-1
  SET /A ayear =%nyear%-2
  
  mkdir "2. "%nyear%
  rename "2. "%myear% "3. "%myear%
  move "3. "%ayear% %cd%\Archive\
  rename %cd%\Archive\"3. "%ayear% %ayear%
  
  SET RootDir=%cd%\2. %nyear%
  echo %RootDir%
  SET SubA="1. January","2. February","3. March","4. April","5. May","6. June", "7. July", "8. August" "9. September", "10. October", "11. November", "12. December" 
  SET SubB="1. Campaigns","2. Ads","3. Internal","4. Facebook","5. Instagram"
  FOR %%A IN (%SubA%) DO FOR %%B IN (%SubB%) DO IF NOT EXIST "%RootDir%\%%~A\%%~B" MD "%RootDir%\%%~A\%%~B"
  EXIT
  </code></pre>
  
  <p>I have tested the individual parts of the script and they work fine but when it runs as a whole I get the following error:</p>
  
  <pre><code>The process cannot access the file because it is being used by another process. 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Z9fcu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z9fcu.png" alt="error message"></a></p>
  
  <p>Any help would be appreciated.</p>