Setting Modification Date From Commandline

Andrew Warren awarren at synaptics.com
Fri Dec 21 19:16:00 PST 2007


Rick Quatro wrote:

> I am looking for a command line program that will allow me to set
> the modification date and time of a file.

Rick:

A Google search for something like "file timestamp windows" will find hundreds of freeware Windows utilities for setting a file's timestamp arbitrarily... But if you just want to set a file's timestamp to the current time -- like the Unix "touch" command -- you can do it from the DOS command line with:

  copy /b FILENAME.EXT +,,

Microsoft suggests this batch file to make it even easier:

  @echo off
  if %1.==. goto end
  if not exist %1 goto end
  copy /b %1 +,, > nul
  echo %1 touched.
  :end

Save the file somewhere in your path as touch.bat, then just type:

  touch FILENAME.EXT

to set FILENAME.EXT's timestamp.

-Andrew




More information about the framers mailing list