0

I have been using the below script and it works great except it only creates a folder with the current date on it. I need one to do the same but create a folder with yesterday's date on it. Thank you in advance.

Echo For /f "tokens=1,2,3,4,5 delims=/. " %%a in ('date/T') do set CDate=%%d.%%b.%%c Echo %cdate% MD "U:\folder\%Cdate%" move /-y "U:\Folder**.PDF" "U:\Folder\%Cdate%"

Pause

Hodg0899
  • 1
  • 1
  • 2
  • possible duplicate of [how to make folder name with yesterday's date?](http://stackoverflow.com/questions/24834551/how-to-make-folder-name-with-yesterdays-date) – JosEduSol Jan 16 '15 at 15:35

1 Answers1

0
@echo off
set day=-1
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YYYY=%result:~0,4%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "date-yesterday=%yyyy%-%mm%-%dd%"
mkdir "%date-yesterday%"
pause
meatspace
  • 859
  • 16
  • 25