Check and create folder in mac

expand collapsive

Hello folks kinda new here!

Tried the action for executing scripts from hexnode portal to create a folder if it doesn’t already exist on our macs. Ran this command as script I got with some quick google searches.

mkdir -p Data analytics

Here’s the problem though. Its not working as expected and I can’t figure out why since it’s a simple one line command. Any idea what am I getting wrong?

All Replies

  • Hexnode

    Emma Jones


    Hello @zinovia, We’ve got you covered!

    You can check if a folder/directory exists and, if absent, create it by providing the complete path to the folder/directory in the script.

    For example, mkdir –p /Users/Username/Desktop/Data\ analytics will check if a directory named ‘Data analytics’ exists in the Desktop. If not, it will be created.

    Check out more scripts relate to file management from our Sample script repository.

    Hope this answer suits your requirements. Should you need any further assistance, please do not hesitate to reach us!

    Emma Jones
    Hexnode UEM