A colleague came to my rescue on this. He created a VB script for this that also runs the dir command. Here is the content of that:
<pre>
Dim getDate, getDay, getMonth, getYear, oShell, setPath, Response, Yesterday
Set oShell = CreateObject("WScript.Shell")
getDate = Date()-1
getDay = Day(Yesterday)
getMonth = Month(Yesterday)
getYear = Year(Yesterday)
Yesterday = getYear & "-" & getMonth & "-" & getDay
setPath = "cmd /c dir <i>path</i> <i>/variables</i> ><i>FileToPipeResultsTo</i>" & Yesterday & "<i>FileExtension</i>"
oShell.Exec setPath
------------------------------------------------------------------------------------------------
I don't know of an easy way to do it using a BAT. You could need to program the date calculation by yourself in a similar way that the one used <a href="http://www.computing.net/answers/windows-xp/delete-files-older-then-xdays-v2/171309.html">here</a>.
Another option could be to have another bat scheduled to run daily, which writes the current date to a file, and then your other script reads the file created the day before.
In other words, one day, some script does this:
<pre>echo %date% > c:previous_date.txt</pre>
And the next day, your script reads the file, and use that value to rename the desired files.
<pre>for /f %%a in (c:previous_date.txt) do (
set previous_date=%%a
exit /b
)</pre>
------------------------</pre>