I need a script to copy files from a location which contains files from all month. The thing is that I need to copy only the files from yesterday to a temporary location. I've searched alot, but couldn't find a solution.
I have tried in this form. The first part show me the day from yesterday.
@echo off
Set _Source=V:\IngOnline
Set _Dest=D:\SPEtransfer\IngOnline\Temp
set log=D:\SPEtransfer\logIngOnlineTransfer.log
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 "data=%yyyy%-%mm%-%dd%"
echo Yesterday was "%data%"
pause
forfiles /p %_Source% /d -1 "cmd /c copy %_Source%\*.* %_Dest%"