Script to make folder if it does not exist

Hello All,

Well i have googled all around to find a solution. I need a script which can make the Documents / Movies/ Sites / Music folders in home folders and if it has already been made to just skip to end.

The reason for this is because when our users log onto our mac network with there windows account it does not make these folders and they cannot use iMovie to save :frowning:

Your help will be very appreciated.




this script creates the folders in the list (if they don’t already exist), sets the proper privileges and adds the .localized flag to display the folder names automatically in any localized language.

In this version it affects only the current home folder

property folderList : {"Documents", "Music", "Pictures", "Sites", "Public", "Movies"} -- the english names are obligatory!

set homeFolder to POSIX path of (path to home folder)

set {TID, text item delimiters} to {text item delimiters, ","}
set theFolders to folderList as text
set text item delimiters to TID
-- create folders in case they don't exist and set the proper privileges
do shell script "/bin/mkdir -m 700 -p  " & quoted form of homeFolder & "/{" & theFolders & "}/"
-- add the localized flag to display the folder names in the appropriate language
repeat with oneFolder in folderList
	do shell script "/usr/bin/touch " & quoted form of (homeFolder & oneFolder & "/.localized")
end repeat

I could kiss you thank you very much you have made a lot of teacher and kids very happy :slight_smile:


Quick question will this only make the folder if it does not exist?


which part of if they don’t already exist is mistakable? :wink:

Its a little odd our problem its basiclly if any one of the folders does not exist to then make the folder. For some reason some people have the sites folder but not movies and music. Would it skip all if it detects one or does it check each folder?

Sorry for the stupid questions I am only ok with a little bit of scripting.


yes, only the non-existing folders will be created.
The touch line works similar: If the .localized file does not exist, it will be created, otherwise only the modification date will be changed