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.


fritfald
2021-08-19T11:20:51Z
II want to get and insert the folder destinations from a list of folders in a file file.txt.

file.txt looks like this:
/MR/Tmpio/002/LON_pdf/LON_FOAarkiv/*.pdf \\srv-perspektiv\Ax\FOA_Randers\Loensedler
/MR/Tmpio/003/LON_pdf/LON_FOAarkiv/*.pdf \\srv-perspektiv\Ax\FOA_Koege\Loensedler
/MR/Tmpio/004/LON_pdf/LON_FOAarkiv/*.pdf \\srv-perspektiv\Ax\LFS\Loensedler

eg /MR/Tmpio/002/LON_pdf/LON_FOAarkiv/*.pdf is the source
and
\\srv-perspektiv\Ax\FOA_Randers\Loensedler is the target folder

I have managed to extract folder names it and write it into a file with the Write File function.
{REGEX(Replace|{TASK(PrevTask,StdOut)}|(?<=\s)[\D]+|)}
{REGEX(Replace|{TASK(PrevTask,StdOut)}|^([\S]+)|)}

but how do I get the above REGEX into the folder path as a valid string?
Sponsor
Forum information
Support
2021-09-07T15:17:13Z
Originally Posted by: fritfald 

II want to get and insert the folder destinations from a list of folders in a file file.txt.

file.txt looks like this:
/MR/Tmpio/002/LON_pdf/LON_FOAarkiv/*.pdf \\srv-perspektiv\Ax\FOA_Randers\Loensedler
/MR/Tmpio/003/LON_pdf/LON_FOAarkiv/*.pdf \\srv-perspektiv\Ax\FOA_Koege\Loensedler
/MR/Tmpio/004/LON_pdf/LON_FOAarkiv/*.pdf \\srv-perspektiv\Ax\LFS\Loensedler

eg /MR/Tmpio/002/LON_pdf/LON_FOAarkiv/*.pdf is the source
and
\\srv-perspektiv\Ax\FOA_Randers\Loensedler is the target folder

I have managed to extract folder names it and write it into a file with the Write File function.
{REGEX(Replace|{TASK(PrevTask,StdOut)}|(?<=\s)[\D]+|)}
{REGEX(Replace|{TASK(PrevTask,StdOut)}|^([\S]+)|)}

but how do I get the above REGEX into the folder path as a valid string?



Hi, apologize for the delayed response on this. Do you still need help on this? Please send an email to support@visualcron.com and refer to this thread if you do.
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
fritfald
2021-09-08T07:11:15Z
kind of.
REGEX cant read single lines, so I had to do it in steps, since I have 50 lines.

Did this:
loop start
Task1:
Read the file with the paths with a powershell command:
Get-Content D:\FOAWINBATCH\fil\hent_finans_klar_til_afsend.txt | Select-Object -first 1

Task2:
In the next step I had to remove the firstline in the file and save it en another file named _temp, powershell command:
Get-Content D:\FOAWINBATCH\fil\hent_finans_klar_til_afsend.txt | Select-Object -Skip 1 | Out-File D:\FOAWINBATCH\fil\hent_finans_klar_til_afsend_temp.txt

Task3:
Next step i regex the folder name from the StdOut from the first step:
Foldername in FTP, where to download from Remote Filefilter:
{REGEX(Replace|{TASK(e9a26187-f749-4c80-96f7-f36aca9c816f|StdOut)}| .*|)}
Foldername in FTP where to download to:
{REGEX(Replace|{TASK(e9a26187-f749-4c80-96f7-f36aca9c816f|StdOut)}|^([^ ]+ ){1}|)}

Task4:
Finally I copy the _temp file to the original filename, so in step 1 it kan read it again, just one less line.
It loops through the step as long as hent_finans_klar_til_afsend.txt have a size > 0.

it works, but if you have an easier way to do this, you are welcome to comment on this solution :-)
Support
2021-09-10T14:32:24Z
Originally Posted by: fritfald 

kind of.
REGEX cant read single lines, so I had to do it in steps, since I have 50 lines.

Did this:
loop start
Task1:
Read the file with the paths with a powershell command:
Get-Content D:\FOAWINBATCH\fil\hent_finans_klar_til_afsend.txt | Select-Object -first 1

Task2:
In the next step I had to remove the firstline in the file and save it en another file named _temp, powershell command:
Get-Content D:\FOAWINBATCH\fil\hent_finans_klar_til_afsend.txt | Select-Object -Skip 1 | Out-File D:\FOAWINBATCH\fil\hent_finans_klar_til_afsend_temp.txt

Task3:
Next step i regex the folder name from the StdOut from the first step:
Foldername in FTP, where to download from Remote Filefilter:
{REGEX(Replace|{TASK(e9a26187-f749-4c80-96f7-f36aca9c816f|StdOut)}| .*|)}
Foldername in FTP where to download to:
{REGEX(Replace|{TASK(e9a26187-f749-4c80-96f7-f36aca9c816f|StdOut)}|^([^ ]+ ){1}|)}

Task4:
Finally I copy the _temp file to the original filename, so in step 1 it kan read it again, just one less line.
It loops through the step as long as hent_finans_klar_til_afsend.txt have a size > 0.

it works, but if you have an easier way to do this, you are welcome to comment on this solution :-)



We do not have any regex experts indoors unfortunately, so it will be hard to help you with the regex part here. But if there's any other easier way, I will ask a few colleagues and check with them. At least it works for you, which is great!

I do however think that the simplest way would be using VC string functions, like String.Left, String.Right and Stirng.IndexOf and String.LastIndexO
so you can parse your input like
1. based on space in between like String.Left(input,1, String.IndexOf(' '))
2. Get source folder and filename String.Left(input,1, String.LastIndexOf('/'))4
Michael
Support
http://www.visualcron.com 

Please like  VisualCron on facebook!
Scroll to Top