Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Where can I get the touch utility for Windows?

I have tried this one at CodeProject but it did not change directorys.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

you can use powershell to do this as well. I have the following function in my $profile

function touch([string] $filename)
{
$curTime = Get-Date
$touchFile = get-item $filename
$touchFile.CreationTime = $curTime
$touchFile.LastAccessTime = $curTime
$touchFile.lastWriteTime = $curTime
}
share|improve this answer
    
I think that this could be extended to allow the date to be supplied –  benPearce Jun 10 '09 at 5:22

There are several solutions at http://stackoverflow.com/questions/51435/windows-version-of-the-unix-touch-command

While most of them suggest getting Cygwin (my bias too) or some other unix utilities, there is one answer describing a windows method.

copy /b filename.ext +,,

Another simple solution from the same answer is to get the Cygwin.dll and touch.exe copied locally in your windows system. It will work better if you want to process directories recursively.

share|improve this answer
    
how does this copy command allow you to change the date time stamp –  benPearce Jun 10 '09 at 2:11
    
The /b treats the file as binary and the +,, tell it to copy the file back to the same place effectively updating the timestamp. But, since you ask, i prefer the Cygwin, touch.exe method. –  nik Jun 10 '09 at 2:15
    
but that only allows you to set the timestamp to now –  benPearce Jun 10 '09 at 2:47
    
Ah, you should use the Cygwin method with touch then -- it will be touch -t [[CC]]YY]MMDDhhmm[.ss]. –  nik Jun 10 '09 at 3:11

Your Answer

 
discard

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.