title: Batch file creating a log file
body: <p>This should be simple not sure why it isn't working...
  I have a batch file with 2 cmds and am trying to get it to write the output to a log file.</p>
  
  <p>Here is what is in my batch file:</p>
  
  <pre><code>PUSHD "\\My Very Long\Exact Directory\" &gt;&gt;logfile.txt
  for /f "skip=7 eol=: delims=" %%F in ('dir /b /o-d *.xlsm') do del "%%F" &gt;&gt;logfile.txt
  </code></pre>
  
  <p>The PUSHD is because this file is in on a remote file storage <code>\\My Very Long\Exact Directory\</code> and I want the actions to be taken within the directory where the batch file is, and not the directory that it is being called from. The second command cleans up the directory by deleting old copies.</p>
  
  <p>When I run the batch, by either calling it from the remote server, or by double clicking it straight away, the cmd window opens and runs the clean up. It will create a file in the directory called 'logfile.txt' but it is empty.</p>
  
  <p>The process that calls this batch file from the remote server is scheduled, and I want to see what happened when this was called later. How do I get the results to write to the log file. I imagine it should look very similar (it not the same) as what the cmd window pops opens and shows.</p>
  
  <p>I reference this other post: <a href="https://stackoverflow.com/questions/20484151/redirecting-output-from-within-batch-file">Redirecting Output from within Batch file</a></p>
  
  <hr>
  
  <p>Adding more as I have been informed PUSHD nor DEL have outputs...
  I put a pause in the file to capture the cmd window. I am looking to capture this information and of course any errors that occur. Maybe this is the wrong approach?</p>
  
  <pre><code>X:\File Path\BackUps&gt;PUSHD "\\My Very Long\Exact Directory\"  1&gt;&gt;logfile.txt
  Y:\File Path\BackUps&gt;for /F "skip=7 eol=: delims=" %F in ('dir /b /o-d *.xlsm') do del "%F"  1&gt;&gt;logfile.txt
  Y:\File Path\BackUps&gt;del "2015 CSLD Weekly Comment Analysis 2015-10-10  9_11_09 .xlsm"  1&gt;&gt;logfile.txt
  Y:\File Path\BackUps&gt;del "2015 CSLD Weekly Comment Analysis 2015-10-10 23_55_29 .xlsm"  1&gt;&gt;logfile.txt
  Y:\File Path\BackUps&gt;pause
  Press any key to continue . . .
  </code></pre>