You are visitor number ????? since 2 August 2006

Go to Howard Kaikow's home page

Copyright © 2006-2007 by Howard Kaikow. All rights reserved.

Date: 16 July 2007

Author: Howard Kaikow <kaikow@standards.com>

Subject: Change File Times Program


Download the latest version of the Change File Times Program

Also, see the Change Path Times ("Path Times") program

Overview

There are circumstances in which "incorrect" file times are recorded. These include:

The Change File Times ("FileTimes") program may be used to change the Access, Creation, and Modification times for a file. The program should work with either a file or a directory file.

Access Times

When changing times for directories, you should change times for each subdirectory before you change times for the parent directory.

The Change Path Times program cheats and makes a second pass on the directories, hoping to reduce this problem.

The Change File Times program is designed to work on one file at a time. In batch processing mode, you might be able to cheat by sorting the batch file appropriately.

Requirements

The program was compiled using Microsoft Visual Basic 6 (with SP 6).

In order to run this program, you will need to have the following installed:

Restrictions

I have developed the program using Microsoft Windows 2000. The program will not work on operating systems older than Microsoft Windows 2000.

The Forms used by this program were designed using a screen resolution of 1280 x 1024, hopefully, there will be no problems at other screen resolutions.

Installing the program

Run the program InstallChangeFileTimes.exe.

The program will be installed in a directory of your choosing and will be assigned to the Howard Kaikow group in the Start menu.

The program may be uninstalled from Add/Remove Programs in the Control Panel.

Output

The program creates a log file named LogChangeFileTimes.txt. The file will be created in the directory in which ChangeFileTimes.exe is installed. If the file does not exist, the file will be created by the program. If the file exists, the program will append to the end of the file.

The log file is very important, and should be checked after running the program. The log file lists the times that were changed, and any errors encountered. If you inadvertently change a file time, the information in the log file may be used to restore the file times to a one second resolution.

Running the program

You may run the program from the Start menu, or by double-clicking on the ChangeFileTimes.exe file, or by using a shortcut to that file.

When you run the program, a Form will be displayed that looks something like the following.

If you select Process batch, you will be asked to identify a file listing the changes you wish to make.

If you select Copy file times, or Copy directory times, you will be asked to select a file/directory for which the times are to be modified and a file/directory from which the times are to be copied. A Form will be displayed that looks something like the following.

If you select Change file times, or Change directory times, you will be asked to select a file/directory for which the times are to be modified. A Form will be displayed that looks something like the following.

You also may select Copy file times, or Copy directory times, and then select, as appropriate, Change file times or Change directory times.

Control

Purpose

Enforce time order If checked, the program will not change a time if Modification Time is earler than Creation Time, or if Access Time is earler than either Creation Time or Modification Time.
Preserve Resolution

If unchecked, a time will be recorded only if it is different than the original time.

If checked, a further comparison will be made using a resolution of one second.

Creation Time

If checked, the file's new Creation Time may be changed when the Change Times button is used.

If unchecked, the new Creation Time will be set to the original Creation Time, and the Creation Time will not be changed when the Change Times button is used.

Modification Time If checked, the file's new Modification Time may be changed when the Change Times button is used.

If unchecked, the new Modification Time will be set to the original Modification Time, and the Modification Time will not be changed when the Change Times button is used.

Access Time If checked, the file's new Access Time may be changed when the Change Times button is used.

If unchecked, the new Access Time will be set to the original Access Time, and the Access Time will not be changed when the Change Times button is used.

Back Select another file or directory file.
Exit Exit the program.

Change Times

Change the selected times. The times for the file are not changed until the Change Times button is used.
Original Lists the times currently recorded for the file.

New

Lists the times that may be recorded for the file when the Change Times button is used. Several mechanisms are provided for selecting the new file times.
Date and Time Pickers

Set a new time.

Each part of the date and time is treated as a separate field. If you highlight a field, you can use the up and down arrow keys to change the value of the field. In addition, if you click on the down arrow next to the date, a calendar can be used to select a date.

Now Sets the new time to the current time. Behavior depends on whether Enforce date order is checked.

UTC

Sets the new time to the UTC for the original time.
Access Sets the new Creation Time, or Modification Time, to the new Access Time.
Creation Sets the new Access Time, or Modification Time, to the new Creation Time.
Modification Sets the new Access Time, or Creation Time, to the new Modification Time.

Time Selection Mechanisms

For each of the file times, you may choose a new time as follows:

Time Resolution

It is not possible to preserve the full accuracy of a recorded time value using typical user interfaces.

For example, when you select a file, "7/4/2006 01:29:10" might be displayed for a file time. However, the internal respresentation is more precise than a one second resolution.

If you use the Date and Time Picker, or any other, controls to change the time, and then use the Date and Time Picker controls to reset back to the original time, it is highly likely that the result will be different than the internal respresentation for the original time.

If you check the Preserve Resolution control, the program willl compare the new and original times, and not make a change if there is no difference using a one second resolution.

If you uncheck the Preserve Resolution control, you may inadvertently change a time by reducing the accuracy of its internal representation.

If you wish to set a new time to the original time, uncheck the box used to select the time to be changed.

If you wish to set a new time to the UTC time, use the UTC button.

If you wish to set a new time to the current time, use the Now button.

Batch File

If you selected Process batch, you must identify a Batch File listing all the changes you wish to make.

The program will process each record in the Batch File. The LogChangeFileTimes.txt file will indicate the outcome of processing each record.

Each record must be terminated with a CARRIAGE RETURN character followed by a LINE FEED character.

Each parameter in each record must be separated from any following parameter in the record by a TAB character.

A record will be ignored if any duplicate or erroneous parameter is detected.

Purpose

How to specify

Comment

Placing a SEMICOLON character at the beginning of a record will cause the record to be ignored.

Destination file

The file for which times are to be modified is the Destination file. All records must identify a Destination file

The Destination file is identified by D=filespec, where filespec is the full file path, including the filename and filename extension, not enclosed in quote characters.

Source file

The file from which times are to be copied is the Source file. A record may identify a Source file only if it is intended to copy the times from the Source file to the Destination file.

The Source file is identified by S=filespec, where filespec is the full file path, including the filename and filename extension, not enclosed in quote characters.

Copying the times from the Source file to the Destination file.

If you have identified a Source file, you may identify which of the times are to be copied.

The times may be identified using a single parameter consisting of one, or more, with no duplicates, of the following:

C to copy Creation Time.
M to copy Modification Time.
A to copy Access Time.

If this parameter is omitted, all three times will be copied.

Changing the times in the Destination file when a Source file is not identified.

If you have not identified a Source file, you must identify which of the times are to be changed.

The times are identified using a separate parameter for each time, with no duplicates, as follows:

The Creation Time is specified by C=timespec, where timespec is a time, not encosed in quote characters, acceptable to the Visual Basic 6 IsDate function.

The Modification Time is specified by M=timespec, where timespec is a time, not encosed in quote characters, acceptable to the Visual Basic 6 IsDate function.

The Access Time is specified by M=timespec, where timespec is a time, not encosed in quote characters, acceptable to the Visual Basic 6 IsDate function.