SetVarValidFilePath: Set Variable with Valid Windows File Path

SetVarValidFilePath creates variables like a regular SetVar but transforms the value to a valid Windows file path.

All non-Windows-filepath-compliant characters: :?\"<>|{}*;^ are replaced by an underscore: _
Front slash / is replaced by backslash \

Tag Attributes

Attributes

Attribute Values

Value Description

Variable Name

N/A

Any unreserved name valid in XML. Reserved names are listed on: Variables

Variable Value

N/A

Any string or number.

NewFile

True / False 

If set to True, the file name shall be modified with a number increment so that it becomes unique.

Example Script


XML
<ytriaAutomation>
	<SetVar MyPath="MuhFolder/My Export at 06:06:06 {is it large? nobody | knows;}"/>
	<SetVarValidFilePath MyPath="{%MyPath%}" MyOtherPath="C:\dev\Temp_XML\ProcessError.xml" NewFile="true"/>
	<Echo Value="{%MyPath%}"/>
	<Echo Value="{%MyOtherPath%}"/>
</ytriaAutomation>


In this example, two file path are generated:

automation-SetVarValidFilePath-1.gif

Since ProcessError.xml already exists and NewFile is set to "true" the new file name variable contains ProcessError (2).xml
automation-SetVarValidFilePath-2.gif