title: Batch file to find newest file in folder then copy and rename it to another folder
body: <p>Found the same question here.. I am trying to use the code but for my data. I am in no way a programmer.. I can take almost any code and make it work for me however. </p>
  
  <p><a href="https://stackoverflow.com/questions/3063487/how-to-code-a-batch-file-to-copy-and-rename-the-most-recently-dated-file?answertab=oldest#tab-top">How to code a batch file to copy and rename the most recently dated file?</a></p>
  
  <p>Here is my </p>
  
  <pre><code> @echo on
   setLocal DisableDelayedExpansion
   pushd  N:\
   setLocal EnableDelayedExpansion
  
   for /f "tokens=* delims= " %%G in ('dir/b/od') do (set newest=%%G)
  
   copy %newest% G:\Server_Files\AMI_DATA\TEXT_FILES\NewFile.csv
  
   PAUSE
   POPD
  </code></pre>
  
  <p><strong>And the results...</strong></p>
  
  <pre><code>C:\Documents and Settings\belcherj\Desktop\AMI_BATCH&gt;setLocal DisableDelayedExpa
  nsion
  
  C:\Documents and Settings\belcherj\Desktop\AMI_BATCH&gt;pushd  N:\
  
  N:\&gt;setLocal EnableDelayedExpansion
  
  N:\&gt;for /F "tokens=* delims= " %G in ('dir/b/od') do (set newest=%G )
  
  N:\&gt;(set newest=System Blink Count__2012-06-27 01_00_46.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-06-28 01_00_32.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-06-29 01_00_33.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-06-30 01_00_42.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-01 01_00_32.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-02 01_00_31.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-03 01_00_29.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-04 01_00_39.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-05 01_00_34.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-06 01_00_31.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-07 01_00_32.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-08 01_00_30.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-09 01_00_40.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-10 01_00_29.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-11 01_00_44.csv )
  
  N:\&gt;(set newest=System Blink Count__2012-07-12 01_00_34.csv )
  
  N:\&gt;copy System Blink Count__2012-07-12 01_00_34.csv G:\Server_Files\AMI_DATA\TE
  XT_FILES\NewFile.csv
  The system cannot find the file specified.
  
  N:\&gt;PAUSE
  Press any key to continue . . .
  </code></pre>
  
  <p>I think it has something to do with the spaces in the file names.. I tried some other code i found and it gave the same results. Im close just need a little push. 
  Thanks for you time and help. </p>