|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 /O:[-]acdeginorstuz /Q /R[:acw] file /S[[+]n] /T[acw[u]][hh:mm[:ss[.dd]]] file...|
|file||One or more files whose date and/or time stamps are to be changed.|
No error messages
Force read-only files
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. If you don't specify any arguments, TOUCH will display its command dialog.
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.
If you don't enter any arguments, TOUCH will display its command dialog.
TOUCH sets three internal variables:
|%_touch_dirs||The number of directories touched|
|%_touch_files||The number of files touched|
|%_touch_errors||The number of errors|
|/=||Display the TOUCH command dialog to help you set the filename and command line options. The /= option can be anywhere on the line; additional options will set the appropriate fields in the command dialog.|
|/A:||Select only those files that have the specified attribute(s) set. See Attribute Switches for information on the attributes which can follow /A:.|
You can specify /A:= to display a dialog to help you set individual attributes.
|/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|
|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.|
|/O:...||Sort the files before processing. You may use any combination of the sorting options below. If multiple options are used, the listing will be sorted with the first sort option as the primary key, the next as the secondary key, and so on:|
|n||Sort by filename and extension, unless e is explicitly included. This is the default.|
|-||Reverse the sort order for the next sort key|
|a||Sort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension.|
|c||Sort by compression ratio|
|d||Sort by date and time (oldest first); also see /T:acw|
|e||Sort by extension|
|g||Group subdirectories first, then files|
|i||Sort by description|
|o||Sort by owner|
|r||Reverse the sort order for all options|
|s||Sort by size|
|t||Same as d|
|z||Same as s|
|/R||The /R option permits duplication of the time stamp of ref_file (which must immediately follow the /R, and can be a file or subdirectory). For example, if you recompile an old program (e.g., to obtain an intermediate file that has long been deleted) you may want to use the timestamp of the source file that was last changed as the time stamp of the newly built duplicate of the original object file to prevent a "make" from attempting to rebuild everything else in the project as shown in the example:|
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.pdf %temp\tcmd.pdf
copy /u ftp://ftp.jpsoft.com/help/tcmd.pdf %temp\tcmd.pdf
|In the above example TOUCH creates an empty file with the time stamp of your already existing help file; COPY updates the empty file if a newer version is available (beware of time stamp 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.
If you specify a + followed by a number after the /S, TOUCH will not modify any time stamps until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not modify anything in \a or \a\b.
|/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).|
|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.