What do you use when you want to update the date-modified field of a file on Windows?

  1. commands accessible via C++, .NET, C#, or something native to Windows (Vista preferably)
  2. tools/applications preferably free, and if possible open source as well

Edit: there is already a page for applications as pointed out by CheapScotsman here.

If anyone knows how I can do this via C++, C#, WSH or something similar, well and good, else I would think everything else is covered in the linked question.

link|improve this question
feedback

migrated from stackoverflow.com Jul 21 '09 at 23:26

This question came from our site for professional and enthusiast programmers.

8 Answers

up vote 5 down vote accepted

If you feel like coding it yourself, .NET offers the File.SetLastAccessTime, File.SetCreationTime and File.SetLastWriteTime methods.

link|improve this answer
As good as it gets. Thanks. – facepalmd Jul 22 '09 at 19:44
feedback

You could also install Cygwin which gives you Touch as well as a plethora of other *NIX commands.

link|improve this answer
1  
can't live on windows without cygwin. – jweede Sep 10 '09 at 12:32
And cygwin without mintty is pretty lame. – Ahe Jan 25 '10 at 14:30
feedback

Here's a simple regfile I wrote to add right-click "touch" in Windows explorer. It'd be easy to script it, too, since it just calls:

cmd.exe /c copy %1+nul %1 /by
link|improve this answer
1  
Useful and handy too. Thanks. – facepalmd Jul 21 '09 at 22:12
And don't forget copy nul some_file to create an empty file (which is what I see touch most often used for). – Joey Aug 27 '09 at 6:28
Ack! Zip file inaccessible (something about brinkster22.com needing to be the referring site). Jon, can you update this? – Dan7119 Mar 28 '11 at 14:22
feedback

How about codeproject "Touch for Windows": http://www.codeproject.com/KB/applications/touch_win.aspx

edit; Same question as here: http://stackoverflow.com/questions/51435/windows-version-of-the-unix-touch-command/51439

link|improve this answer
Thanks. I missed that in my search which resulted in loads of touch screen phone related stuff. Probably needs a better tag label I guess. – facepalmd Jul 21 '09 at 21:52
feedback

There are Windows ports of many Unix utilities. Have a look at unxutils or GnuWin32 projects.

link|improve this answer
feedback

From a similar question on Stack Overflow.

For updating timestamps (ignoring the other functionality of touch), I'd go with:

copy /b filename.ext +,,
link|improve this answer
Thank You.This was useful +1 :) – Pavitar Apr 25 '11 at 14:26
feedback

There is an utility which adds touch to the context menu (right-click) of a folder. More information is available here

link|improve this answer
feedback

The four alternatives mentioned above, plus four more not mentioned here, can be found in the answer to a similar question: "Windows Recursive Touch Command"

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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