title: Batch File Adding Date To Filename
body: <p>I wrote a batch file 2 years ago that seemed to work great making a backup copy of an excel spreadsheet daily.  All of a sudden 1 day it stopped working properly and began assigning the variables literally instead of pulling the actual date so it just began overwriting itself every day.  </p>
  
  <p>I went from getting this file name: 
  Tasty Schedule 2018 - 04-30-2018</p>
  
  <p>To now getting this filename:
  Tasty Schedule 2018 - ~4,2-~6,2-~0,4</p>
  
  <p>Looking at the code it seems obvious where the values are coming from but I am not sure why the date is no longer being pulled.  Im assuming there had to be some type of system update that changed something to cause this?  What is the best way to fix this?  Please see my current code below:</p>
  
  <pre><code>@echo off
  for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set dt=%%a
  set YYYY=%dt:~0,4%
  set MM=%dt:~4,2%
  set DD=%dt:~6,2%
  set HH=%dt:~8,2%
  set Min=%dt:~10,2%
  set Sec=%dt:~12,2%
  
  set stamp=%MM%-%DD%-%YYYY%
  
  copy "J:\TROY C\2018 Schedule\Tasty Schedule 2018.xlsx" "J:\Joe's Folder\ChocScheduleBackUps\Tasty Schedule 2018 - %stamp%.xlsx"
  </code></pre>