Question:
Every day after midnight I have to copy log file from day before.
Log names are in format exYYMMDD.log. So today (22.10.2011) I would have to copy file named ex111021.log into some directory.
Is it possible to do it in batch script? If not I could use powershell but would prefer not as it is not installed on my server.
Edit:
With help of Siva Charan I created this (polish win7 – echo %date% prints YYYY-MM-DD)
1 2 3 |
set /a yest_Day = %date:~8,2%-%var:~-2,1% copy ex%date:~2,2%%date:~5,2%%yest_Day%.log targetDir |
Answer:
In powershell :
1 2 3 4 5 |
$YesterdayfileName = [string]::format("{0:yyMMdd}", ((Get-Date).adddays(-1)))+".log # today 22/20/2011 gives 111021.log Copy-Item $YesterdayfileName c:\temp |