Forfiles version you use is not native XP command. It's an older version of the utility, which was originally distributed with one of the W2K Resource Kits (I think it goes even to NT Resource kit, although I'm not sure). There is nothing wrong using that on XP per se , but if you look closely into it's syntax, it says (emphasis mine):
-d[+|-][DDMMYY|DD] Select files with date >= or <=DDMMYY (UTC)
or files having date >= or <= (current date - DD days)
Note UTC in the description. This means (1.1) forfiles uses different time stamps that you think it does - unless your system time is UTC (no offset), no daylight savings.
This will be probably easier with an example. I'm UTC+1, daylight savings time.
(today's date - 2012-09-19)
- Create file and do a dir:
2012-09-19 00:14 5 zzz_utc.txt
it has today's date, so it should not be selected by forfiles,let's check it:
FORFILES -pc:\temp -mzzz_utc.* -d-1 -c"CMD /C Echo @FILE"
zzz_utc.txt
But it does get selected! Why? Let's look at file UTC times (following command is run from powershell):
ls .\zzz_utc.txt |select LastAccessTime,LastAccessTimeUTC
LastAccessTime LastAccessTimeUtc
-------------- -----------------
2012-09-19 00:15:11 2012-09-18 22:15:11
As you can see, TimeUtc - the one used by (1.1) forfiles is from yesterday! That's why it gets selected by the tool.
d+1it is looking for files that are greater than 1 day from today inclusive and if I dod-1it is looking for files less than 1 day from today inclusive. So basically if I wanted to look for files that were older than 1 day, I would have to dod-2. Is that right? – PeanutsMonkey Sep 18 '12 at 20:08dir /t:w) You could also try-d-DDMMYYinstead of-d-1and see if that yields the desired result. – Ansgar Wiechers Sep 18 '12 at 20:15.BAT, but I'd have to think about it -- it doesn't strike me as easy. – Scott - Слава Україні Sep 18 '12 at 23:23%date:~3,2%%date:~0,2%%date:~-2%when the system date format is MM/DD/YYYY. – Ansgar Wiechers Sep 19 '12 at 06:31