Community forum

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


klewis10367
2017-09-06T18:55:09Z
I have files that are named XXXX~-XXXX~XXXX~XXXX~XXXX.pdf
What I am trying to accomplish is to replace the first ~- with a ~ in the file, but keeping everything else named the same. I am struggling with the Rename File task. Any help would be appreciated.
Sponsor
Forum information
ErikC
2017-09-07T06:13:50Z
Hi klewis10367,

What you can do is as follows:

Use the rename file task.
You could use a file mask to be sure of the file name convention (is regex):
.{4}~-(.{4}~){3}.{4}\.pdf

In the rename setting we only check the Post Process checkbox and also uses some regex:
{REGEX(MatchGetGroup|{NEWNAME()}|(.{4})~-((.{4}~){3}.{4}\.pdf)|1)} delimiter {REGEX(MatchGetGroup|{NEWNAME()}|(.{4})~-((.{4}~){3}.{4}\.pdf)|2)}

What is happening here?
{REGEX(MatchGetGroup|{NEWNAME()}|(.{4})~-((.{4}~){3}.{4}\.pdf)|1)}

From the newname, which still is the original name, use the regex (.{4})~-((.{4}~){3}.{4}\.pdf)
Using the () I split the filename in groups, (.{4}) is group 1 and ((.{4}~){3}.{4}\.pdf) is group 2
The ~- is not in a group, I excluded them.

I placed group 1 first, than the new dilimiter and than group 2. This will rename the file with only a new delimiter after the 1st XXXX.
So this is your solution:
{REGEX(MatchGetGroup|{NEWNAME()}|(.{4})~-((.{4}~){3}.{4}\.pdf)|1)}~{REGEX(MatchGetGroup|{NEWNAME()}|(.{4})~-((.{4}~){3}.{4}\.pdf)|2)}

Sure, there are more solutions to this, this is just one of them.

Regards
Erik
Uses Visualcron since 2006.
klewis10367
2017-09-12T12:34:41Z
Thanks for the help. But a couple questions:

1) What do i put in the new name mask: as it will not let me leave it blank.
2) Also, i have a folder structure with many files to loop through. i am assuming I need to use a file variable somewhere in the string. Where would I put that.
thomas
2017-09-12T12:57:06Z
Maybe I am missing something here, but it seems an ordinary replace should work?

Capture.PNG
klewis10367
2017-09-12T19:10:17Z
Thanks Thomas, that did it. Perfect.
Scroll to Top