I would like to know the cleanest method for checking whether a folder exists:
- I need to verify if certain directories (with dynamic paths) exist, based on the following conditions:
* For each variable (serial), construct a path and check if the folder exists
Ex: \\server\main\<serial>\ or \\server\main\archive\<serial>\
I know that the FileWait component can retrieve information about files present in a directory, which makes it possible to capture folder paths for later use.
Is there a cleaner solution, or should I simply set up a Python script?
---------------------------------
Bonjour,
J’aimerais savoir quelle est la méthode la plus propre pour vérifier l'existance d'un dossier :
- Je dois vérifier si certains répertoires (avec des chemins dynamiques) existent, en fonction des conditions suivantes :
* Pour chaque variable (serial), construire un chemin et verifie si le dossier existe
Ex : \\server\main\<serial>\ ou \\server\main\archive\<serial>\
Je sais que le composant FileWait permet d’obtenir des informations sur les fichiers présents dans un répertoire, ce qui offre la possibilité de récupérer des chemins de dossiers pour une utilisation ultérieure.
Existe-t-il une solution plus propre, ou devrais-je simplement mettre en place un script Python ?
Best Answer
H
Harshit Upadhayay
said
18 days ago
Hello
The Wait for Files (FileWait) action is not the best fit here. It is a polling action designed to detect files on the Runtime engine filesystem, with a timeout and a polling interval. It is not meant for a one-off folder existence check.
Recommended approach: file property fields
xDI exposes file_exists and file_is_directory as boolean property fields on a File metadata. They can be queried from a process through SQL Operation actions.
In your File metadata, right-click the File and choose New > Property Field. Create file_exists and file_is_directory.
In your process, query these fields for the path you want to test. Use one query for \\server\main\<serial>\ and one for \\server\main\archive\<serial>\.
Publish the result to a process parameter with the SQL To Parameters action. It takes the first cell of the query result and supports a Boolean type. You can also set a defaultValue and choose whether the action fails when no record is returned.
Use the parameter in an execution condition or a branch. For example, skip the serial, raise a notification, or create the folder with the Make a directory action.
To cover many serials, put these steps in a repeated step or a sub-process that receives the serial as a parameter.
Things to check
The checks run on the Runtime engine filesystem, not on the Designer machine. The Runtime server must be able to reach the share.
File permissions are evaluated for the user running the Runtime or Designer. That account needs read access to the UNC path.
Alternative
If you prefer a single step, a scripting action (Java Native Scripting or Bean Scripting Framework) can test the path and set a variable. This runs inside xDI, so an external Python script is not required.
The Wait for Files (FileWait) action is not the best fit here. It is a polling action designed to detect files on the Runtime engine filesystem, with a timeout and a polling interval. It is not meant for a one-off folder existence check.
Recommended approach: file property fields
xDI exposes file_exists and file_is_directory as boolean property fields on a File metadata. They can be queried from a process through SQL Operation actions.
In your File metadata, right-click the File and choose New > Property Field. Create file_exists and file_is_directory.
In your process, query these fields for the path you want to test. Use one query for \\server\main\<serial>\ and one for \\server\main\archive\<serial>\.
Publish the result to a process parameter with the SQL To Parameters action. It takes the first cell of the query result and supports a Boolean type. You can also set a defaultValue and choose whether the action fails when no record is returned.
Use the parameter in an execution condition or a branch. For example, skip the serial, raise a notification, or create the folder with the Make a directory action.
To cover many serials, put these steps in a repeated step or a sub-process that receives the serial as a parameter.
Things to check
The checks run on the Runtime engine filesystem, not on the Designer machine. The Runtime server must be able to reach the share.
File permissions are evaluated for the user running the Runtime or Designer. That account needs read access to the UNC path.
Alternative
If you prefer a single step, a scripting action (Java Native Scripting or Bean Scripting Framework) can test the path and set a variable. This runs inside xDI, so an external Python script is not required.
N. gbetinsanon
Hello,
I would like to know the cleanest method for checking whether a folder exists:
- I need to verify if certain directories (with dynamic paths) exist, based on the following conditions:
* For each variable (serial), construct a path and check if the folder exists
Ex: \\server\main\<serial>\ or \\server\main\archive\<serial>\
I know that the FileWait component can retrieve information about files present in a directory, which makes it possible to capture folder paths for later use.
Is there a cleaner solution, or should I simply set up a Python script?
---------------------------------
Bonjour,
J’aimerais savoir quelle est la méthode la plus propre pour vérifier l'existance d'un dossier :
- Je dois vérifier si certains répertoires (avec des chemins dynamiques) existent, en fonction des conditions suivantes :
* Pour chaque variable (serial), construire un chemin et verifie si le dossier existe
Ex : \\server\main\<serial>\ ou \\server\main\archive\<serial>\
Je sais que le composant FileWait permet d’obtenir des informations sur les fichiers présents dans un répertoire, ce qui offre la possibilité de récupérer des chemins de dossiers pour une utilisation ultérieure.
Existe-t-il une solution plus propre, ou devrais-je simplement mettre en place un script Python ?
Hello
The Wait for Files (FileWait) action is not the best fit here. It is a polling action designed to detect files on the Runtime engine filesystem, with a timeout and a polling interval. It is not meant for a one-off folder existence check.
Recommended approach: file property fields
xDI exposes
file_existsandfile_is_directoryas boolean property fields on a File metadata. They can be queried from a process through SQL Operation actions.file_existsandfile_is_directory.\\server\main\<serial>\and one for\\server\main\archive\<serial>\.defaultValueand choose whether the action fails when no record is returned.Things to check
Alternative
If you prefer a single step, a scripting action (Java Native Scripting or Bean Scripting Framework) can test the path and set a variable. This runs inside xDI, so an external Python script is not required.
Related Documentation
Thank you
Harshit Upadhayay
Hello
The Wait for Files (FileWait) action is not the best fit here. It is a polling action designed to detect files on the Runtime engine filesystem, with a timeout and a polling interval. It is not meant for a one-off folder existence check.
Recommended approach: file property fields
xDI exposes
file_existsandfile_is_directoryas boolean property fields on a File metadata. They can be queried from a process through SQL Operation actions.file_existsandfile_is_directory.\\server\main\<serial>\and one for\\server\main\archive\<serial>\.defaultValueand choose whether the action fails when no record is returned.Things to check
Alternative
If you prefer a single step, a scripting action (Java Native Scripting or Bean Scripting Framework) can test the path and set a variable. This runs inside xDI, so an external Python script is not required.
Related Documentation
Thank you
1 person likes this
-
File external resolver with encrypted value
-
Timeout on Mapping/Webservice call
-
UNIQUE TEMP TABLE NAMES
-
Previous step name from a sub-process of execute delivery
-
Dropping multiple tables at once in XDI
-
Freeze Designer and corrupted workspace
-
FileWait/Move/Copy: FileInclude with space
-
Change SVN user in the Designer
-
How to Specify the JVM used by the Designer?
-
Sybase IQ error: "Transaction %Id1% attempted to access %tableName% created by transaction %Id2%"
See all 74 topics