watchDirectory Help

Help Home
Creating New Tasks
Running Tasks
Task History

Plugins

Standard versus Pro
Version History

Search

See Also...




Free 30 day evaluation!
Standard version: $79 USD
Professional version: $149 USD
Buy Now!

 

German Helpfile

German Helpfile

French Helpfile

French Helpfile

Spanish Helpfile

Spanish Helpfile


Privacy Policy

Dynamic naming allows you to give "target files" and directories a name based on the detected file and the current date/time. Dynamic naming is supported by several watchDirectory plugins:
Automatically Copy files,
Automatically Sort files,
Automatically Unzip files,
Automatically Zip files,
Automatically Upload (FTP) files (backslashes are automatically replaced with forward slashes) and
Automatically Rename files

An example of a dynamic name would be:

D:\Target\{year}{month}{day}\{hour24}\{extension}\{filename}
When the file Hello.txt is detected, this dynamic name resolves to:
D:\Target\20051231\23\txt\Hello.txt
(depending on the date and time when the file is detected).
New directories are always automatically created as needed.

Supported tags when you use Dynamic Naming

The example values are for the file C:\Monitor\subdir\sub\file.txt, and C:\Monitor is the directory being watched.

tag nameDescriptionExample value
{drive}The drive letter of the monitored directory.C
{dir}The directory where the detected file is found.Monitor\subdir\sub
{monitoreddir}The directory that is watched by this task.Monitor
{relativedir}If the new file is found inside a sub-directory of the monitored directory, this variable contains the complete sub-directory name.subdir\sub
{firstdir}The first directory name, directly below the monitored directory.subdir
{parentdir}The name of the directory where the file is found.sub
{filename}The name and extension of the file.file.txt
{filetitle}The name without extension of the file.file
{extension}The extension of the file.txt
{originalfull}The complete path of the file.Monitor\subdir\sub\file.txt
{originalrelative}The path of the file, starting from the monitored directory.subdir\sub\file.txt
{owner}The account name that owns the file. Note that this will always show "John" when you edit a task, when you run the task it will be replaced by the real owner.John
Several date and time related tags, such as {year}, {monthname} and {hour24} that should be obvious.
Those date/time related tags use the current system time. If you want to use the timestamp of the detected file instead, you can add ":cr" (when was the file created), ":lm" (last modified) or ":la" (last accessed) to the tag.
So, for example, {monthname} uses the system time to get the month, but {monthname:lm} uses the "last modified" timestamp of the file to determine the month.

It is also possible to do some limited arithmetic on these date/times. Suppose you want to use the last-modified date as a dynamic name, for example
D:\TargetDirectory\{year:lm}-{month:lm}-{day:lm}\{filename}
However, you want to "add 1 day" to this timestamp. You can do this by entering the following "date modifier" somewhere:
{lm:+1d}
so it becomes
D:\TargetDirectory\{lm:+1d}{year:lm}-{month:lm}-{day:lm}\{filename}
This will add 1 day to the last-modified date. You can also add or subtract hours ({lm:+22h}) minutes ({lm:+10m}) and seconds ({lm:+10s}). You can combine multiple date modifiers, for example
{lm:+1d-30h-2m+4s}
This will add 1 day, subtract 30 hours, subtract 2 minutes and finally adds 4 seconds.

To change the "System Date/Time", use {cu:+1d} (cu = current)
To change the "Last Modified Date/Time", use {lm:+1d}
To change the "Last Accessed Date/Time", use {la:+1d}
To change the "Creation Date/Time", use {cr:+1d}

{taskname}The name you give to this task.AutoCopy
{runnumber}The number that watchDirectory assigns to this run.
This number can be used to find more information in the Task History viewer.
17
{eventnumber}A unique number that watchDirectory assigns to the current event.
This number can be used to find more information in the Task History viewer, but also to create a unique directory or filename.
Eventnumbers are unique per task.
16292

Supported Functions when you use Dynamic Naming

FunctionDescriptionExample
{left{num,text}} Returns the first num characters from text {left{3,{extension}XXX}}

This will return the first 3 characters from the file extension. For files without an extension, XXX is returned.

{right{num,text}} Returns the last num characters from text {right{5,00000{runnumber}}}

This will return a 5 digit runnumber with leading zeroes.

{substring{start,length,text}} Returns "length" characters from text, starting at position "start". The first character of the text is position 0 (zero). {substring{0,3,{monthname}}}

This will return the string "Oct" (in the month October).

{reverse{text}} Returns text reversed {reverse{abc}}

This will return the string "cba".

{lower{text}} Returns text in lowercase {lower{{monthname}}}

This will return the string "october" (in the month October).

{upper{text}} Returns text in uppercase {upper{{monthname}}}

This will return the string "OCTOBER" (in the month October).

{title{text}} Returns text in "title-case" - The first letter of each word is made uppercase, other characters made lowercase. {title{{filename}}}

This will return the string "Hello World.txt" (when the file "HELLO WORLD.txt" is detected).

{stringbefore{tofind,completestring}} Returns text from "completestring" up until "tofind", or "completestring" if "tofind" is not found. {stringbefore{ober,{monthname}}}

This will return the string "Oct" in the month October.

{stringafter{tofind,completestring}} Returns text from "completestring" starting after "tofind", or "completestring" if "tofind" is not found. {stringafter{_,{filetitle}}}

This will return everything after the first underscore from the filename.

{cutright{num,text}} Removes the last "num" characters from text. {cutright{4,abcdefg}}

This will return the string abc.

{environment{variablename}} Returns the value of an environment variable. If you run watchDirectory as a service, only System environment variables are available. {environment{COMPUTERNAME}}

This will return the string "MYCOMPUTER" (if your computer is named like that).

{replace{old,new,string}} The replace function searches in "string" for occurences of "old" and replaces them with "new". If "old" is not found, "string" is not changed. If "new" is empty, all occurrences of "old" are removed. {replace{\,/,{originalfull}}}

This will replace all backslashes to forward slashes. If {originalfull} is Monitor\subdir\sub\file.txt,
Monitor/subdir/sub/file.txt is returned.

{replace{\,,{originalfull}}}

This will remove all backslashes. If {originalfull} is Monitor\subdir\sub\file.txt,
Monitorsubdirsubfile.txt is returned.

{sequence{the-sequence-filename}} Reads the-sequence-filename into "counter", increments the counter and writes it back to the-sequence-filename. If the file does not yet exist, the value "1" is used, and the file is created. The new counter value is returned. {sequence{c:\My Data\Sequences\{taskname}.txt}}

If this function is used by the task "AutoCopy", and the file C:\My Data\Sequences\AutoCopy.txt does not exist yet, it is replaced by the number "1". This number is also written to AutoCopy.txt.
The next time this function is evaluated, it is replaced by "2", and "2" is also written to AutoCopy.txt.

{random{low,high}} Returns a random number between low and high (inclusive). {random{1,2}}

Returns the number 1 or 2 randomly.

{code{dllname,parameters}} Loads the DLL, which must be in directory <install dir>\Resolvers, and calls it with the given parameter.
There is only one such dll installed with watchDirectory and it is called resolveExample.dll. The full source-code of this example is available for download.

The resolveExample checks if the file passed as a parameter already exists. If it does, it returns <filename>_1.extension (or _2 if _1 also exists).
If the file does not exist, it will return the filename "as is".
{code{resolveExample.dll,{drive}:\{originalfull}}}