TOUCHME


PURPOSE   OPERATION   OPTIONS   COMMAND_LINES   RELATED PROGRAMS


Author: Dan Mares, dmares @ maresware . com
Portions Copyright © 2019-2022 by Dan Mares, and Mares and Company, LLC
Phone: 678-427-3275
Last update: Feb. 14, 2022

One liner: Command line to reset file times. Similar to Linux touch.

GET touchme.exe     THIS IS A COMMAND LINE PROGRAM

NOTE: This is a command line program. Should/Must be run as administrator. However, even as administrator, WIN7 and later may not allow access to certain protected directories. You should test the access as needed.

top

Purpose

TOUCHME, in its basic operation is designed to operate similar to the linux touch program which will update the file date/times to current date/time.

When used with appropriate options, it will change the target files' modified, access or create date/time to any specific date/time as per the (--TOUCH=...)option provided. It can change one or all of the MAC date/times based on the --TOUCH= options format used.

This program is quite helpful when needing to alter or reset the files MAC times.


Top

Operation

TOUCHME will update every target (-f option) files' date/time to the current date time (default --TOUCH). This option --TOUCH without any additional modifier resets all three filetimes to the current date/time. This is the traditional Linux operation of the Linux touch program.

With the appropriate option mask or modifiers TOUCHME will alter any one, two or all three of the MAC date/times to a value provided on the command line by the user.

The (--TOUCH=....) option format has three sections, and its syntax/format is very specific, so read the options section to determine correct syntax of the option to modify the date or time of the files. If the format is not exact, then the results are not determined. With the appropriate recurse (-r) option, the program will recurse the directory/path and process all files it finds in the path. When running from root, use this -r option cautiously.

A sample command to modify all MAC times to the date 20190701, time 140000 would be:
- -TOUCHME=mac!20190701:123456:789
Thats a minus-minus (--) option.
To alter only the Modified date, to midnite: --TOUCHME=m!20190701  leave off the time to have time set to midnite. If the time part of the modifier is left off, then the new time is set to 00:00:00 (midnite). If the miliseconds is left off, then milliseconds is set to 000.

Notice the tags, 'm',"a","c", will dictate which of the date/times will be modified. Use one or all to determine which dates are modified.

Theoretically, with multiple --TOUCH= options, different date/times can be set. For instance:
--TOUCH=mc!20190701:123010    --TOUCH=a!20190710:120000
This would set the Modified and Created to one date, and the Access to another date for the same command line.

NOTE NOTE NOTE
The program does make some adjustments for any local U.S. daylight saving time offset. It is a confusing explanation, but here is a sample of the adjustments. If you enter a time setting of
--TOUCH=MAC!20220201 (without any time settings) you would expect it to be set for midnight Feb. 01

c:>TOUCHME.exe wiping.doc --TOUCH=MAC!20220201
gets the following date setting, notice it is set -1 hour from requested
C:dir:>wiping.doc    01/31/2022 23:00:00c  01/31/2022 23:00:00w  01/31/2022 23:00:00a
To get correct date setting for the daylight offset in february set one hour off:
c:>touchme wiping.doc --TOUCH=MAC!20220201:010000
c:dir>wiping.doc     02/01/2022 00:00:00c  02/01/2022 00:00:00w  02/01/2022 00:00:00a
Notice proper midnight was set. Clear as mud???
Test the process in your own timezone before actual use. If the time you set is ouside the daylight offset, you shouldn't have too much trouble. But the +-1 hour will still have effect.


top

Options

All options should be preceded by a (-) minus sign (with the exception of the primary --TOUCH option which is the main purpose of this program.

-p + path(s)    If more than one directory is to be looked at, then add the paths here as appropriate. (-p    c:\windows    d:\work )

--path=single_path_to_traverse;  Only a single path is used in this -- option. The -p option is preferred.

-f + filespec    If more than one file type is needed, add them here. (-f    *.c    *.obj    *.dll )

If the above options are used, the program builds a matrix of paths and file types. It searches all the requested directories for all the requested file types, thus producing a total of all the files in all the paths requested.

(C:>touchme -p c:\tmp c:\windows -f   c:\work\*.c    *.dll )

--filename=single_file_type    Only a single filetype is used in this -- option.

-x + filespec    E(x)clude these file types from listing (same format as -f option) (-x thesefiles.txt)

--exclude=single_file_type_to_exclude    Only a single filetype is used in this -- option.

--TOUCH  This is the default to modify file date/times MAC, to current date/time. Identicle to the Linux touch operation.

--TOUCH=[mac]!YYYYMMDD[:hhmmss][:milliseconds]  Use --TOUCH=... to modify a specific, Modify, Access, Create, or all three date/times. And set the date/time to any specific date/time using the below described format masks.

Item 1: --TOUCH=    minus minus TOUCH equal.
Item 2: [mac]  one or all of the 'm','a','c' designators for which date/time to modify. No brackets. --TOUCH=mac
Item 3: !YYYYMMDD   exclamation point followed by YYYYMMDD format of the date to set
The YYYYMMDD mask must be 4 digit year, two digit month and day. --TOUCH=mac!20190704

Item 4: :hhmmss   Optional time field. A mandatory colon, :hhmmss item to reset time to.
If a time item is needed, then the colon/time format is included. The time must be hhmmss format, and be in 24 hour mode (take into consideration any DST +- hour), with leading zeros where necessary. 2 digit hour, 2 digit minute, 2 digit seconds, item are required format (ie :140500), for 2:05PM. 24 hour format is required. IF NO time format is included, then the new time is defaulted to midnite 000000.    See command lines for some examples. And the final complete format is: --TOUCH=mac!20190704:120105

Item 5: :milliseconds   Optional, colon, then 3 digit ddd (:999) item to reset the milliseconds of time to.
Default is that the milliseconds will be set to 000. If a milliseconds time item is needed, then this additional colon/millisecond time format is included. The millisecond time must be ddd three digit format. As shown here for a time: 120101:999 Sets the time to 12 hours, 01 minute, 01 second, and 999 milliseconds

-1 + logfile  Create an accounting/log file. This file is ALWAYS overwritten so if you wish to preserve it, make a copy before running the program. Example: "-1 accounting.txt"

-g + #    Where the # is replaced by a number indicating: list all files ‘g’reater than # days old. You can use a -gl pair to bracket file ages. [OLDER]=50

-l + #    (ell, not one) Where the # is replaced by a number indicating: list all files ‘l’ess than # days old. You can use a -gl pair to bracket file ages. To get todays files, use (-l 1) [NEWER]=10

-g + mm-dd-yyyy (greater than, older)
-l + mm-dd-yyyy[acw] (less than, younger) (that's and ell, not a one)
--younger=mm-dd-yyyy (obvious)
--older=mm-dd-yyyy (obvious)
Process only those files (g)reater (older) than or (l)ess than (newer) than this mm-dd-yyyy date. The date MUST be in the form mm-dd-yyyy. It MUST have two digit month and days (leading 0 if necessary), and it MUST have a 4 digit year. The date given mm-dd-yyyy is NOT included in the calculation. Ie. if today was 01-10-2003 and you entered -l 01-09-2003 you would only process todays files. If you wanted to include those on 01-09, you should have entered -l 01-08-2003. If you use the keyword "younger" or "older" you must format the date as mm-dd-yyyy also.

The [acw] literals, choose which time to base the mm-dd-yyyy test on Any or all [acw] can be used. If none used, then default is w

	examples: -l 10-20-2005a, -g
12-05-2005w, -l 12-20-2005a -g 10-01-2005c
examples: -l 10-20-2005acw, -g 12-05-2005wc

-L + #    Where the # is replaced by a number indicating: list all files less than # bytes in size. (-L 100000) [LESSTHAN]=100000

-G + #    Where the # is replaced by a number indicating: list all files greater than # bytes in size. You can use a -GL pair to bracket file sizes. (-G 10000) (-G 10000 -L 100000) [GREATER]=10000


Top

Command Lines

C:>touchme
/* shows help screen */

C:>touchme -?
/* obtain help screen */

NOTE: use the -p, -f options to add/modify files which will be processed

C:>touchme  -p d:\work\
/* process all files starting at this directory */

C:>touchme  -f *.bat
/* process all .bat files starting at this directory, and recurse down the tree */

C:>touchme    -r
/*recurse thru directories. Default is NOT RECURSE. add this option to any other -p, -f options */

C:>touchme    --TOUCH
/* change all MAC date/times to current date/time, similar to Linux touch command. */

C:>touchme    --TOUCH=m!20190501
/* process all files and change Modify date to 20190501, and defaults to midnite 000000 time

C:>touchme    --TOUCH=ma!20190501:140000
/* process all files and change Modify and Access date/time to 20190501, and sets time to 140000 (2PM)

C:>touchme    --TOUCH=mac!20190501:140000
/* same as above, except changes all three MAC times to 20190501, and sets time to 140000 (2PM)

C:>touchme    --TOUCH=mc!20190501:140000    --TOUCH=a!20190704:120001
/* same as above, except changes create/modify to 20190501, and sets access to 20190704.. read the times for yourself.

C:>touchme    --TOUCH=mac!20190501:140000:999   
/* same as above, except changes all times, and adds a 999 millisecond to the time.


Related Programs

Diskcat

Top