TOUCH |
|
| Purpose: | Change a file's time stamps, and optionally create a file. |
| Format: | TOUCH [/A:[[-][+]rhsdaecjot] /C [/D[acw][date] /E /F /I""text"" /N /Q /R[:acw]file /Sn /T[acw[u]][hh:mm[:ss[.dd]]] file... |
| file | One or more files whose date and/or time stamps are to be changed. |
/A: |
Attribute select |
No action |
|
Create file |
Quiet |
||
Date |
Reference file |
||
No error messages |
Subdirectories |
||
Force read-only files |
Time |
||
Match descriptions |
|
|
File Selection:
Supports attribute switches, extended wildcards, ranges, multiple file names, subdirectories, catalog files, and include lists.
Usage:
TOUCH is used to change the date and / or time of a file. You can use it to be sure that particular files are included or excluded from an internal command, backup program, compiler MAKE utility, or other program that selects files based on their time and date stamps, or to set a group of files to the same date and time for consistency.
TOUCH should be used with caution, and in most cases should only be used on files you create. Many programs depend on file dates and times to perform their work properly. In addition, many software manufacturers use file dates and times to signify version numbers. Indiscriminate changes to date and time stamps can lead to confusion or incorrect behavior of other software.
By default, TOUCH affects only files. You must utilize the /A: option to include directories. /A:D will select directories only.
| /A: | Select only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:. |
| /C | Create file (as a zero-byte file) if it does not already exist. You cannot use wildcards with /C, but you can create multiple files by listing them individually on the command line. |
| /D | If neither /R nor /D are specified, the current date is used. If the /D option is specified without date, TOUCH will not modify the date even if /R is also specified. If the /D option is followed by date, and /R is not specified, date is used. The date must not be quoted. If both /R and /D with date are specified, the one specified later in the command takes effect. |
On an LFN drive, you can specify which of the date fields should be set by appending a, c, or w to the /D option:
| a | Last access date |
| c | Creation date |
| w | Last modification (write) date |
If you append a u to the date field, TOUCH will set the UTC date rather than the local date.
| /E | Suppress all non-fatal error messages, such as "File not found." Fatal error messages, such as "Drive not ready," will still be displayed. This option is most useful in batch files. |
| /F | The file systems normally do not permit changing timestamps of read only files. The /F option forces date and time change of read-only files by temporarily removing the read only attribute. |
| /I"text" | Select files by matching text in their descriptions. See Description Ranges for details. |
touch /r project.c project.obj
Another use could be to synchronize files without rendering the current version inaccessible during the synchronization:
touch /c /r c:\jpsoft\tcmd.chm %temp\tcmd.chm
copy /u ftp://jpsoft.com/help/tcmd.chm %temp\tcmd.chm
In the above example TOUCH creates an empty file with the timestamp of your already existing help file; COPY updates the empty file if a newer version is available (beware of timestamp synchronization across the Internet!).
On an LFN drive, you can specify which of the date/time fields should be used by appending a, c, or w to the /R option:
| a | Last access date and time (on VFAT volumes access time is always midnight). |
| c | Creation date and time |
| w | Last modification (write) date and time |
| /S | TOUCH all matching files in the specified directory and its subdirectories. Do not use /S with @file lists. See @file lists for details. |
If you specify a number after the /S, TOUCH will limit the subdirectory recursion to that number. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only affect the "a", "b", and "c" directories.
| /T | If neither /R nor /T are specified, the current time is used. If the /T option is specified without time, TOUCH will not modify the time even if /R is also specified. If the /T option is followed by time, and /R is not specified, time is used. (Time must not be quoted). If both /R and /T with time are specified, the one specified later in the command takes effect. |
On an LFN drive, you can specify which of the time fields should be set by appending a, c, or w to the /T option:
| a | Last access time (on VFAT volumes access time is always midnight). |
| c | Creation time |
| w | Last modification (write) time |
If you append a u to the time field, TOUCH will set the UTC time rather than the local time.