Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


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 =

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 =

So, will this work?

share|improve this question
up vote 2 down vote accepted

Powershell to use Unix touch seems silly to me.

Instead, just use native Powershell cmdlets.

This article covers it:


Get-ChildItem -Path $youFolder -Recurse | Foreach-Object {
    if ($_.LastWriteTime -ge [DateTime] "1/31/2013 9:00AM")
        $_.LastWriteTime = Get-Date

Should do the trick.

share|improve this answer
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 May 21 '13 at 16:30
Sorry, forgot the checking. Added now. This does essentially what you ask but uses an If statement instead of the where-object – AthomSfere May 21 '13 at 17:00
Brilliant! It works. I had to remove all of the new lines to run it from the command line but it worked. – atwright147 May 22 '13 at 9:01
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. – AthomSfere May 22 '13 at 11:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.