2
I have found the following question on ServerFault:
Windows recursive touch command
Which partially answers my question with this answer:
Windows recursive touch command
However, I would like to touch all files (in root and sub folders (recursively)) that are newer than 31st January 2013 (31/01/13). How would I go about doing this?
I have PowerShell 2 available.
UPDATE:
I have found that this scriptlet gets all of the files that I am after:
Get-ChildItem C:\path\to\files -recurse | Where-Object { $_.LastWriteTime -ge [DateTime] "1/31/2013 9:00AM" }
But I am not sure how to combine it with the "touch" command:
(ls file).LastWriteTime = DateTime.now
The following seems logical but I cannot test it as backing up my files will screw up my files' modified date/times:
(Get-ChildItem C:\path\to\files -recurse | Where-Object { $_.LastWriteTime -ge [DateTime] "1/31/2013 9:00AM" }).LastWriteTime = DateTime.now
So, will this work?
Sorry but I think you have missed the point of my question. I want to filter for files that are newer than a given date, then change their timestamp to now. I have code for both but am not sure how to put them together. Thanks for the help so far though. – atwright147 – 2013-05-21T16:30:09.377
Sorry, forgot the checking. Added now. This does essentially what you ask but uses an If statement instead of the where-object – Austin T French – 2013-05-21T17:00:29.840
Brilliant! It works. I had to remove all of the new lines to run it from the command line but it worked. – atwright147 – 2013-05-22T09:01:54.357
Yes, I had it in a script form so to run it from the console it would have had to be moved to a one-line form. – Austin T French – 2013-05-22T11:30:50.887