Updating the Date and Time Stamps on Files
This article was previously published under Q69581
This article has been archived. It is offered "as is" and will no longer be updated.
The following MS-DOS command updates the date and time stamps of a filenamed "EXAMPLE" without altering the contents of the file. This is similarto the TOUCH utility found in XENIX and in some third-party MS-DOStoolkits.
COPY /B EXAMPLE +,,
The COPY command can concatenate a file onto an existing file whenused in the form:
COPY FILE1+FILE2In this example, the contents of FILE2 are appended to FILE1, leavingFILE2 unchanged. When copying in this mode, the COPY command switchesto ASCII mode where the ^Z (0x01A) end-of-file marker is honored.
Therefore, with the above command, the /b forces the COPY command intobinary mode, the filename is the file to be updated, the + (plus sign)indicates that a file is to be appended, and the ,, (commas) areplaceholders for the remaining parameters (which are not included inthis example). Because the file to be appended is not specified, theCOPY command will append nothing and only update the time and datestamps for the file.
The following batch file, TOUCH.BAT, can be used to automate theprocess:
@echo off if %1.==. goto end if not exist %1 goto end copy /b %1 +,, > nul echo %1 touched! :endThis batch file requires one parameter, the file to be "touched." Ifthe parameter is not supplied, line 2 will cause the batch file toexit without doing anything. If the specified file does not exist,line 3 will cause the batch file to exit also.
6.22 3.20 3.21 3.30 3.30a 4.00 4.01 5.00 5.00a 6.00 6.20 stamp
Article ID: 69581 - Last Review: 12/04/2015 09:06:41 - Revision: 2.1
Microsoft MS-DOS 3.1, Microsoft MS-DOS 3.2 Standard Edition, Microsoft MS-DOS 3.21 Standard Edition, Microsoft MS-DOS 3.3 Standard Edition, Microsoft MS-DOS 3.3a, Microsoft MS-DOS 4.0 Standard Edition, Microsoft MS-DOS 4.01 Standard Edition, Microsoft MS-DOS 5.0 Standard Edition, Microsoft MS-DOS 5.0a, Microsoft MS-DOS 6.0 Standard Edition, Microsoft MS-DOS 6.2 Standard Edition, Microsoft MS-DOS 6.21 Standard Edition, Microsoft MS-DOS 6.22 Standard Edition
- kbnosurvey kbarchive KB69581