TOUCH.EXE

From RAD Studio
Jump to: navigation, search

Go Up to Command-Line Utilities Index

TOUCH.EXE sets the date and time of the listed files to be your system's current (or specified) date and time.


Command-Line Syntax

touch [<options>] <filename> [<filename>...] 

If TOUCH cannot find a file that matches the name you specify, it creates a zero-length file with the correct date stamp. To suppress automatic file creation, use the -c option.

TOUCH accepts long file names. <filename> can contain the wildcard characters * and ? to "touch" more than a single file at a time. Use the -s option to update matching files in all subdirectories.

Before you use TOUCH, make sure your system's internal clock is set correctly.

Command-Line Options

TOUCH.EXE supports the command-line options listed in the following table:

TOUCH Command Line Options

Option Description
-h
-h2
  • -h -- Displays help information (same as typing TOUCH without options or file names).
  • -h2 -- Displays expanded help information.
-c

Do not generate the file if it does not already exist. The default is to create it.

-D

Allows directory names to be "touch"ed (when wildcards specified).

-d
-t

Sets the date or/and time of the file to the specified date or/and time.
The -d and -t options work in the same way. Whether they set the date or time or both date and time by one option depends on the used format of the specified parameters. The following formats are supported:

  • <nn><dd><hh><mm>[<yy>] -- The UNIX format syntax. This format sets both date and time. Here:
    • <nn> -- Sets two digits of the month.
    • <dd> -- Sets two digits of the day.
    • <hh> -- Sets two digits of the hour.
    • <mm> -- Sets two digits of the minute.
    • <yy> -- Sets two digits of the year. Optional.
  • <hh>:<mm>:[<ss>] -- This syntax sets the time only. Here:
    • <hh> -- Sets two digits of the hour.
    • <mm> -- Sets two digits of the minute.
    • <ss> -- Sets two digits of the second. Optional.
  • <mm>-<dd>[-<yy>]
<mm>/<dd>[/<yy>] -- These two syntax rules set the date only. Here:
    • <nn> -- Sets two digits of the month.
    • <dd> -- Sets two digits of the day.
    • <yy> -- Sets two digits of the year. Optional.

Supported ranges of parameters are:

  • month -- 01 - 12,
  • day -- 01 - 31,
  • hour -- 00 - 23,
  • minute -- 00 - 59,
  • sec -- 00 - 59,
  • year -- the last 2 digits of the year representing 1980-2079.

For example,

-t1231235911  //month=12, day=31, hour=23, minute=59, year=11 (year=2011)   
-d0102030400  //month=01, day=02, hour=03, minute=04, year=99 (year=1999)   
-t12/31/11    //month=12, day=31, year=11 (year=2011)   
-d12-31-11    //month=12, day=31, year=11 (year=2011)   
-d12:31:11    //hour=12, minute=31, second=11  
-n

Lists files. The -n option does not change the date or time of matched files.

-r<filename>

Sets the time and date of the files specified in the command line to match the time and date of the <filename> file.

-s

Recurses through subdirectories.

-v

Verbose mode. Shows each file that has been "touch"ed.

-w

Warns about unlocatable files and bad time values. The default is to warn.

-a, -f, -m

-a, -f, -m are quietly ignored for Unix compatibility.


See Also