Updating the Date and Time Stamps on Files

만료된 KB 콘텐츠 고지 사항

이 문서는 Microsoft에서 더 이상 지원하지 않는 제품에 대해 작성되었습니다. 따라서 이 문서는 “있는 그대로" 제공되며 더 이상 업데이트되지 않습니다.


The following MS-DOS command updates the date and time stamps of a file named "EXAMPLE" without altering the contents of the file. This is similar to the TOUCH utility found in XENIX and in some third-party MS-DOS toolkits.


More Information

The COPY command can concatenate a file onto an existing file when used in the form:

In this example, the contents of FILE2 are appended to FILE1, leaving FILE2 unchanged. When copying in this mode, the COPY command switches to ASCII mode where the ^Z (0x01A) end-of-file marker is honored.

Therefore, with the above command, the /b forces the COPY command into binary mode, the filename is the file to be updated, the + (plus sign) indicates that a file is to be appended, and the ,, (commas) are placeholders for the remaining parameters (which are not included in this example). Because the file to be appended is not specified, the COPY command will append nothing and only update the time and date stamps for the file.

The following batch file, TOUCH.BAT, can be used to automate the process:

@echo off
if %1.==. goto end
if not exist %1 goto end
copy /b %1 +,, > nul
echo %1 touched!
This batch file requires one parameter, the file to be "touched." If the parameter is not supplied, line 2 will cause the batch file to exit without doing anything. If the specified file does not exist, line 3 will cause the batch file to exit also.

문서 ID: 69581 - 마지막 검토: 2006. 11. 15. - 수정: 1