ONYX - 9.0 - KB - ifFileExist

Difference in behavior between Windows and Linux

De MappingDoc
Révision datée du 8 janvier 2025 à 08:33 par Jdieu (discussion | contributions) (Page créée avec « Calling the script in the cmd box: </br> </br> "[%PATH_BIN%]/custom/iffolderexist.sh" "[%PATH%]/../foo"</br> </br> With "[%PATH%]/../toto" the directory to check.</br> </... »)
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)
Autres langues :
English • ‎français

A difference in behavior on the ifFileExist box between Windows and Linux:


On Windows, this checks the presence of a file AND a directory.
On Linux, this just checks for the presence of a file (It does not return true if a directory is checked)


To check the presence of a directory, you must go through a param box in cmd and use a shell which returns yes if the directory exists and no otherwise.


Script content:

FOLDER=$1 
if [ -d $FOLDER ]; then
echo "yes"
else
echo "no"
fi


Calling the script in the cmd box:

"[%PATH_BIN%]/custom/iffolderexist.sh" "[%PATH%]/../foo"

With "[%PATH%]/../toto" the directory to check.

PS: The relative path is possible via /../ for example