(Win 8.1 Pro 64b on Intel i7)
All right, I have this fully-automated backup script running daily. However, it turns out, that one of the saved directories (consuming about 25% of the space, and consequently, about the same portion of the total backup time) is modified quite rarely.
I'd now opt to save the directory in question just once weekly. Only that I am not able to figure out how to obtain the day of week in a .bat file.
(Of course, I could do what was done on a HP41C back in olden times and do calculations involving day of month, month of year, and year, but well, I think of it as plan B.)
Is there a way to load the day of week into a .bat variable in a somehow more efficient manner?
11 Answer
Yes, you can.
The following command can be used to get the day:
set day=%date:~0,2%Now %day% contains the date.
Depending on your locale, it may be possible that the date returns a 3 letter day instead of a 2, in which case you would use set day=%date:~0,3%
Explaination: %date% contains a small string that starts with the day, followed by the date in the language used by your OS. The command creates a new variable called day and takes the first 2 characters of the variable %date% as result.
9