======Mark Logic Command: direxists====== Detects if a directory exists on a Mark Logic server ====Synopsis==== direxists [-c uri|-connect uri] directory ====Description==== Checks to see if a directory (uri) exists on a MarkLogic server. Directory URI's must end in slash (/) ||-c,-connect uri||Use the connection string instead of $MLCONNECT|| ||directory|| uri of the direct to check|| ====Example==== Assuming the prefix "ml" is imported as the marklogic module, tests to see if the directory /test/ exists %% if ml:direxists /test/ ; then echo /test/ exists else echo /test/ doesnt exist fi %% Example, safely delete /test/ only if it exists %% ml:direxists /test/ && ml:deldir /test/ %% To check if a document (file) exists use [[MarkLogicExists exists]] ====Implementation==== direxists is implemented as an xsh script which simply calls xdmp:document-properties. The source of the script is %% # return true if diretory exists else return false _opts=$<(xgetopts -a -p "c=connect:" -ps -- "$@") shift $? :query $_opts -b -q <{{ declare variable $uri external ; exists(xdmp:document-properties($uri)//prop:directory) }}> -v uri $1 %% ---- [[ModuleMarkLogic MarkLogic Extension Module]]