Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.

Kevin T
I'm trying to copy files into a directory and changing the file names when it copies, the sources are like this:

PSZLEDSTB3001 rev 1 Instruction 2P FL.PDF
PSZLEDSTB2041 Instruction 4P FS.pdf
CAZLEDHDL1364 Instruction 1P FX.pdf

Where I need to replace from " Instruction*.pdf or PDF" to " Instruction Manual.pdf" then replace all the "spaces" to underscores. So the end result for the list above would be like:

Using wildcards in the replace string doesn't work. Can someone give me some help?
Forum information
I think, for that advanced logic you need to use RegEx. I suggest trying out one of many RegEx forums for a regex string you can use.
Please like  VisualCron on facebook!
If you don't fancy regex, then something like this should work (paste into variables, and you will see)

{STRING(Replace,{STRING(Substring|PSZLEDSTB3001 rev 1 Instruction 2P FL.PDF|0|{STRING(IndexOf|PSZLEDSTB3001 rev 1 Instruction 2P FL.PDF|Instruction)})}, ,_)}Instruction_Manual.pdf

Basically it does this:

1) Find position of the word 'Instruction'

2)Select the substring from start up to the index of 1)

3)Replace all spaces with _

4) Add the last static part of the filename, ie add this => Instruction_Manual.pdf

You have to add some error checking. Eg. if the word Instruction does not exist, it fails.
Kevin T
Hi Thomas,

How do I get the variables of the filenames to substitute the bolded text in the formula?
Hi. Im not at work the nest three weeks, so somebody else will have to show you.

In case you haven't fixed this already, here's a regex for you.

The word "Instruction" followed by zero or more any characters to the end of the string, replaced with "Instruction_Manual.pdf":
{REGEX(Replace|PSZLEDSTB3001 rev 1 Instruction 2P FL.PDF|Instruction.*$|Instruction_Manual.pdf)}

Replace one or more consecutive spaces with a single underscore (allows for fat-fingering of spaces which can be hard to see depending on the font):
{REGEX(Replace|PSZLEDSTB3001 rev 1 Instruction_Manual.pdf| +|_)}

Combine them (of course the actual text string should be replaced by a variable):
{REGEX(Replace|{REGEX(Replace|PSZLEDSTB3001 rev 1 Instruction 2P FL.PDF|Instruction.*$|Instruction_Manual.pdf)}| +|_)}
Scroll to Top