title: Is it possible to undo an action done by a batch file?
body: <p>The question is as the title says. I made a flawed move when moving a selection of files using a batch... It's too late now as I closed it accidentally, but for future reference I'd like the knowledge. The code is as follows: </p>
  
  <pre><code>@ECHO OFF
  SETLOCAL
  SET relroot=g:\Pictures\Uda 18
  (SET relroot=g:\Pictures\Uda 18)
  SET "relroot=g:\Pictures\Uda 18"
  SET "destdir=g:\Pictures\Uda 18\Sets"
  :again
  (SET artist=)
  SET /p artist="Artist? "
  IF NOT DEFINED artist GOTO :eof
  MD "%destdir%\%artist%" 2&gt;nul
  FOR /f "delims=" %%i IN ( 
     ' dir /s /b /a-d "%relroot%\*%artist%*" '
     ) DO (
   ECHO %%i
  MOVE "%%i" "%destdir%\%artist%\%%~nxi" &gt;nul)
  )
  GOTO again
  </code></pre>
  
  <p>The code's purpose it to take an input, find all files with the input in their name within the directory 'Uda 18', and move them to a folder named after the input under the directory 'Uda 18/Sets'. Without thinking, I input '_n.jpg' to move all such files, and it performed the operation. But then I realised I'd moved even things from within 'Uda 18/Sets', and effectively de-organised files I had previously organised by hand. I now realise I need to exclude said directory from the search, but that's not the focus of this question. </p>