Touch File

Declaration

<AMTOUCHFILE FILE="text" CREATIONTIME="date" LASTACCESSTIME="date" LASTWRITETIME="date" TOUCHDATE="YES/NO" />

See Also

Calculate File Checksum | Change Folder | Concatenate Files | Copy File | Create Folder | Delete File | Get File(s) information | Join File | Move File | Read from File | Remove Folder | Rename File | Rename Folder

File System - Touch

Declaration

<AMTOUCHFILE FILE="text" CREATIONTIME="date" LASTACCESSTIME="date" LASTWRITETIME="date" TOUCHDATE="YES/NO" />

See Also

Calculate File Checksum | Change Folder | Concatenate Files | Copy | Create Folder | Delete | Get File(s) information | Join File | Move | Read from File | Remove Folder | Rename

Description

"Touches" one or more files in order to update their creation, last modified and/or last accessed date and time with the selected date/time. To specify more than one file, use wildcard characters (* or ?). To specify multiple file names or wildcard masks, separate them with a pipe symbol (Example: c:\*.txt|c:\*.bak).

Practical Usage

Often useful to categorize dates/times over a range of files. If your output is a whole tree of files, it can be quicker and more convenient to update the date/time of all files rather than it is to navigate through the whole tree looking at update times.

Parameters

General Properties

Property

Type

Req'd

Default

Markup

Description

File

Text

Yes

(Empty)

  1. FILE="C:\foldername\file.txt"

  2. FILE="C:\foldername\*.txt"

  3. FILE="C:\folder1\*.txt|C:\folder2\*.doc"

  4. FILE="file.txt"

The file(s) that should be affected by the update. This can be a fully qualified path and file name (preferred) or a file name only (requires use of the Change Folder action). Wildcard characters (* or ?) may be used to specify files matching a certain mask. To specify multiple file names or wildcard masks, separate them with a pipe symbol (Example: c:\*.txt|c:\*.bak).

Creation Time

Text

No

Disabled

CREATIONTIME=

"%DateSerial(2009,01,01)

+TimeSerial(01,10,00)%"

If enabled, indicates the creation date/time that the specified file(s) should be updated to. Click the Custom button to select from a list of pre-defined date/time ranges. Enable the Expression parameter to enter a date/time expression.

Last Accessed Time

Text

No

Disabled

LASTACCCESSTIME=

"%DateSerial(2009,01,01)

+TimeSerial(01,10,00)%"

If enabled, indicates the last accessed date/time that the specified file(s) should be updated to. Click the Custom button to select from a list of pre-defined date/time ranges. Enable the Expression parameter to enter a date/time expression.

Last Write Time

Text

No

Disabled

LASTWRITETIME=

"%DateSerial(2009,01,01)

+TimeSerial(01,10,00)%"

If enabled, indicates the last write (or last modified) date/time that the specified file(s) should be updated to. Click the Custom button to select from a list of pre-defined date/time ranges. Enable the Expression parameter to enter a date/time expression.

Advanced Properties

Property

Type

Req'd

Default

Markup

Description

Touch Date

Yes/No

No

Yes

TOUCHDATE="YES"

If set to YES, specifies that the date portion of the date/time value will be updated. If set to NO, the date portion will be ignored and only the time portion will be updated. This parameter is set to YES by default.

Touch Time

Yes/No

No

Yes

TOUCHTIME="YES"

If set to YES, specifies that the time portion of the date/time value will be updated. If set to NO, the time portion will be ignored and only the date portion will be updated. This parameter is set to YES by default.

If file is read-only

Text

No

Disabled

READONLYFILE="touch"

Specifies the action that should be performed if the file's attribute is set to read-only. The available options are:

  • Skip - If a file is read-only, it will be skipped.

  • Error - The step will generate an error if a file is read-only.

  • Touch - The file will be touched regardless of whether it is read-only.

Options Properties

Property

Type

Req'd

Default

Markup

Description

Include Subfolders

Yes/No

No

No

SUBFOLDERS="YES"

If set to YES, denotes that, if present, subfolders should be searched for files matching the mask specified in the File parameter. If set to NO (default), subfolders are ignored.

Exclude Mask

Text

No

(Empty)

ARCHIVETURNOFF="YES"

Causes this action to omit files matching the mask(s) specified. File names or wildcard masks may be used. Multiple entries may be specified by separating them with a pipe symbol (Example: *.txt|*.bak).

Only if Newer Than

Date

No

Disabled

ISNEWERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

If enabled, causes this action to only act on files that are newer than the date/time specified. If this parameter is left blank or disabled (default), file dates are ignored.

Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression.

Only if Older Than

Date

No

Disabled

ISOLDERTHAN=

"%DateSerial(2001,10,12) + TimeSerial(00,00,00)%"

If enabled, causes this action to only act on files that are older than the date/time specified. If this parameter is left blank or disabled (default), file dates are ignored.

Click the Custom button to select from a list of pre-defined date parameters. Enable the Expression option to allow entry of a date/time expression.

Attributes Properties

Property

Type

Req'd

Default

Markup

Description

Attributes

Text Options

No

(Empty)

ATTRFILTER="+R+A-H" (delete read-only & archive files but not hidden files)

This group of settings causes this action to filter which files are deleted based on the attribute settings of the source file(s). In visual mode, a group of controls are provided to assist in the selection of this parameter. In markup mode, a single text item must be specified that contains the attributes of the files you wish to delete.

Available Options:

  • R—Read-only: Specifying "+R" causes files with this attribute turned on to be included, "-R" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • A—Archive: Specifying "+A" causes files with this attribute turned on to be included, "-A" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • S—System: Specifying "+S" causes files with this attribute turned on to be included, "-S" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • H—Hidden: Specifying "+R" causes files with this attribute turned on to be included, "-H" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

  • C—Compression: Specifying "+C" causes files with this attribute turned on to be included, "-C" causes files with this attribute turned off to be included, not specifying the letter (default) causes this attribute to be ignored.

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

 

Description: Touch file(s) "C:\Temp\*.txt". Touch date only. Change creation time to "%DateAdd( "d", -30, CStr( Now() ))%". Change last access time to "%DateSerial(2010,06,01)+TimeSerial(12,06,22)%". Change last write time to "%DateSerial(2010,06,01)+TimeSerial(12,06,22)%". Skip read only file(s).

 

<AMTOUCHFILE FILE="C:\Temp\*.txt" CREATIONTIME="%DateAdd( &quot;d&quot;, -30, CStr( Now() ))%" LASTACCESSTIME="%DateSerial(2010,06,01)+TimeSerial(12,06,22)%" LASTWRITETIME="%DateSerial(2010,06,01)+TimeSerial(12,06,22)%" TOUCHDATE="YES" />

 

↑ [Top of Page]