Hide Comments
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:[-]adegnrstu /Q /R[:acw] file /S[[+]n] /T[acw[u]][hh:mm[:ss[.dd]]] file...

 

fileOne or more files whose date and/or time stamps are to be changed.

 

/A:

Attribute select

/N

No action

/C

Create file

/O:..

Order

/D

Date

/Q

Quiet

/E

No error messages

/R

Reference file

/F

Force read-only files

/S

Subdirectories

/I

Match descriptions

/T

Time

 

File Selection:

 

Supports command dialog, 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. 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.

 

TOUCH sets three internal variables:

 

%_touch_dirsThe number of directories touched
%_touch_filesThe number of files touched
%_touch_errorsThe number of errors

 

Options:

 

/=Display the TOUCH command dialog to help you set the filename and command line options. You cannot specify any other arguments on the command line. (Not available in TCC/LE.)

 

/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. (Not available in TCC/LE.)

 

/CCreate 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.

 

/DIf 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:

 

aLast access date
cCreation date
wLast modification (write) date

 

If you append a u to the date field, TOUCH will set the UTC date rather than the local date.

 

/ESuppress 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.

 

/FThe 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.

 

/NDisplay what would occur without actually doing it.

 

/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:

 

nSort by filename and extension, unless e is explicitly included. This is the default.
-Reverse the sort order for the next sort key
aSort names and extensions in standard ASCII order, instead of numerically when numeric substrings are included in the name or extension.
dSort by date and time (oldest first); also see /T:acw
eSort by extension
gGroup subdirectories first, then files
rReverse the sort order for all options
sSort by size
tSame as d
uUnsorted

 

/QDo not display normal messages.

 

/RThe /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.chm %temp\tcmd.chm

copy /u ftp://ftp.jpsoft.com/help/tcmd.chm %temp\tcmd.chm

 

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:

 

aLast access date and time (on VFAT volumes access time is always midnight).
cCreation date and time
wLast modification (write) date and time

 

/STOUCH 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. (Not available in TCC/LE.)

 

/TIf 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:

 

aLast access time (on VFAT volumes access time is always midnight).
cCreation time
wLast modification (write) time

 

If you append a u to the time field, TOUCH will set the UTC time rather than the local time.

Created with Help & Manual 6 and styled with Premium Pack Version 2.41 © by EC Software