I have files in a customer folder.
I have metadata which consists of info on the files that need to be in the folder.
Sometimes some files are missing and need to be created.
Is it possible to check if the files exist, and if some of them don't, send that info via email to a user?
Check if files exist inside folder, send mail if not.
-
- Member
- Posts: 122
- Joined: Fri Jun 12, 2020 11:23 am
Re: Check if files exist inside folder, send mail if not.
Have a look at this app: https://www.enfocus.com/en/appstore/pro ... t-wildcard
This app has a success connection for files that were found and an error connection for files that were not found. When a file is injected along the success connection you know it exists and you can throw it in the recycle bin if you do not have to process it right away. Make sure to keep the original files in place so you do not loose them! And if it follows the error connection you know it does not exist and you can send a mail.
If you have multiple nodes with a filename you will have to split the XML so the files can be checked one by one.
This app has a success connection for files that were found and an error connection for files that were not found. When a file is injected along the success connection you know it exists and you can throw it in the recycle bin if you do not have to process it right away. Make sure to keep the original files in place so you do not loose them! And if it follows the error connection you know it does not exist and you can send a mail.
If you have multiple nodes with a filename you will have to split the XML so the files can be checked one by one.
-
- Member
- Posts: 122
- Joined: Fri Jun 12, 2020 11:23 am
Re: Check if files exist inside folder, send mail if not.
What would be the best option to split xml. Saxonica ?
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: Check if files exist inside folder, send mail if not.
I am using Saxonica for splitting xml.PdFUser5000 wrote: ↑Tue Nov 23, 2021 11:12 am What would be the best option to split xml. Saxonica ?
XSLT Example here:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<!--Splits the XML-file generated in to single XML-files, one for each row-->
<xsl:template match="/">
<xsl:for-each select="/Job/OrderLine">
<!-- Selects which column value to use as filename for the resulting single XML-file. --> <!-- In this case JobNo and OrderLineName is used. -->
<xsl:variable name="filename"><xsl:value-of select="/Job/Header/JobNo"/><xsl:text>_</xsl:text><xsl:value-of select="OrderLineName"/><xsl:text>.xml</xsl:text></xsl:variable>
<xsl:result-document href="{$filename}" method="xml">
<root>
<xsl:copy-of select="OrderLineName" />
</root>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
-
- Member
- Posts: 122
- Joined: Fri Jun 12, 2020 11:23 am
Re: Check if files exist inside folder, send mail if not.
Thanks!magnussandstrom wrote: ↑Tue Nov 23, 2021 9:09 pmI am using Saxonica for splitting xml.PdFUser5000 wrote: ↑Tue Nov 23, 2021 11:12 am What would be the best option to split xml. Saxonica ?
XSLT Example here:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <!--Splits the XML-file generated in to single XML-files, one for each row--> <xsl:template match="/"> <xsl:for-each select="/Job/OrderLine"> <!-- Selects which column value to use as filename for the resulting single XML-file. --> <!-- In this case JobNo and OrderLineName is used. --> <xsl:variable name="filename"><xsl:value-of select="/Job/Header/JobNo"/><xsl:text>_</xsl:text><xsl:value-of select="OrderLineName"/><xsl:text>.xml</xsl:text></xsl:variable> <xsl:result-document href="{$filename}" method="xml"> <root> <xsl:copy-of select="OrderLineName" /> </root> </xsl:result-document> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Re: Check if files exist inside folder, send mail if not.
Please do not mix topics. If you want to contribute more on splitting XML's, create a new topic.
As to the original topic of checking if files exist inside a folder there is now a new app:
https://www.enfocus.com/en/appstore/pro ... -hierarchy
As to the original topic of checking if files exist inside a folder there is now a new app:
https://www.enfocus.com/en/appstore/pro ... -hierarchy
-
- Member
- Posts: 122
- Joined: Fri Jun 12, 2020 11:23 am
Re: Check if files exist inside folder, send mail if not.
Tried Scan hierarchy and ran into a problem. If Hierarchy topfolder is taken from metadata and does not exist, the job goes to problem jobs. One solution is that i use scan hierachy two times in a row, first to check if the folder exists and then if files exist in that folder. Is this a reasonable way to do this?freddyp wrote: ↑Thu Nov 25, 2021 9:53 am Please do not mix topics. If you want to contribute more on splitting XML's, create a new topic.
As to the original topic of checking if files exist inside a folder there is now a new app:
https://www.enfocus.com/en/appstore/pro ... -hierarchy
- magnussandstrom
- Advanced member
- Posts: 378
- Joined: Thu Jul 30, 2020 6:34 pm
- Location: Sweden
- Contact:
Re: Check if files exist inside folder, send mail if not.
Did you try the Inject Wildcard app? I created this flow a few weeks ago. If file don't exist it will retry job 4 times á 5 minutes. Then an error mail is sent. Would this work for you?
- Attachments
-
- inject_wildcard.png (46.42 KiB) Viewed 8324 times
Last edited by magnussandstrom on Mon Jan 17, 2022 10:00 am, edited 1 time in total.
Re: Check if files exist inside folder, send mail if not.
I wrote both Inject Wildcard and Scan hierarchy. A large part of the code is common, but Inject Wildcard will look for files and/or folders and inject them in the flow, while Scan hierarchy will look for file(s) or folder(s) and attach the path(s) as private data (if only one result) or dataset, so that you can use this path later, mainly to archive files in the right subfolder.
The top folder to start the search can be selected or filled in with a variable. If it is filled in with a variable, it is of course possible that the folder does not exist. In that case, Inject Wildcard wil send the job to the error connection, while Scan hierarchy will put the element into failProcess (jobs are hold until the problem is fixed, e.g. if a network path is temporarily not available).
I will correct this in Scan hierarchy and also send the job to the error connection. So expect an update very shortly in your favourite Appstore.
The top folder to start the search can be selected or filled in with a variable. If it is filled in with a variable, it is of course possible that the folder does not exist. In that case, Inject Wildcard wil send the job to the error connection, while Scan hierarchy will put the element into failProcess (jobs are hold until the problem is fixed, e.g. if a network path is temporarily not available).
I will correct this in Scan hierarchy and also send the job to the error connection. So expect an update very shortly in your favourite Appstore.
Laurent De Wilde, Solution Architect @ Enfocus
Re: Check if files exist inside folder, send mail if not.
v2 of Scan hierarchy is now live:
Job is now sent to the error connection if the hierarchy top folder is not found
Job is now sent to the error connection if the hierarchy top folder is not found
Laurent De Wilde, Solution Architect @ Enfocus