Home / Blog / Creating OS Folders and Subfolders with FileMaker

Creating OS Folders and Subfolders with FileMaker

It is very common to generate reoccurring reports in FileMaker that get saved to the user’s computer. Perhaps you would like to organize these reports by day or type. OS level folders and subfolders are a great way to do this. This demo file attached shows you how to create a folder and a subfolder on your user’s computer using FileMaker.

Here’s an overview on how the sample file works:

  • The layout asks you to enter a folder name and a location for the folder (either desktop or documents folder). If the location is the same every time, you can hard code the location in your script.
  • The script confirms that none of these values are empty.
  • The subfolder name is calculated based on the date and time. This ensures that no two subfolders will have the same name, which would cause an error.
  • Check if we are on Windows or Mac.
    • If we are Windows, we run a Send Event script step that makes the directory specified.
    • If we are on Mac, perform applescript to create the main folder, and then perform applescript again to create the subfolder.
  • Let the user know if there was an error or if everything was successful.

You can download the demo file here: CreateFolders.fmp12 (Original File)

Paul McCudden from Peak 14 Solutions has enhanced the file to include parameters in order to account for custom file paths: CreateFolder_PaulMcCudden

21 thoughts on “Creating OS Folders and Subfolders with FileMaker”

  1. Makah,

    Thanks for the sample file – clear, simple, verrry useful! Especially appreciate the platform-independent element given that my knowledge and preferences are for Macs and my PC knowledge is more limited.


  2. Nice clean Applescript. I’ve been doing similar scripts through FM to create job folders and subfolders on a production server. FM then builds the directories in the correct location, based on client name, and will open the folder if it already exists.
    When it’s time to archive, FM knows where the folders are, since it calculated the paths where they are created, and then can grab all the file names and specs in those folders before archiving.

  3. Hello. Very cool setup! So I’m a novice at this, and I’m trying to get the script to create a folder in a specific place on my Windows computer (not on the Desktop or in the Documents directory). For example, I’d like the script to create the FolderName in C:\Users\Username\Music\. Could you possibly help me out?

    1. Makah Encarnacao

      Hi David. I was able to create the new folder in my music folder by doing the following in the sample file:

      • Set the setting on the layout to be documents path, and press the Create Folder button while your script debugger is open
      • I stepped through the script with my script debugger until I got to script step 15, where it sets the $path
      • I opened the data viewer and copied the path, for me it was “/C:/Users/mencarnacao/Documents/”
      • I duplicated the script “Create Folder” and I updated the $path calculation in step 15 to be “/C:/Users/mencarnacao/Music/”.
      • I hard coded it just to test, but you could do a get( documentspath) and then do a substitute with “Documents” and “Music” so it works on multiple machines.
      • I then ran the duplicate script and it worked fine.

      If that doesn’t work you may have a permissions issue on your Music folder. Hope that helps! Good luck!

  4. I am trying to implement a feature in the filemaker database I am creating for my work that uses your technique of making a folder using AppleScript in Filemaker. i am running into some issues since the folder I want to create is on our Apple Server and not on the local machine. The server drive (share) is named “Art_Department”. How would I modify the applescript to create a folder on the server instead of the local desktop or document folder. Any help is greatly appreciated.

  5. Hi David, I would like to create something similar as Makah (Jan 11, 2016). Unfortunately your solution doesn not work for me because: 1. I don’t have Filemaker Advanced, so no debugger and 2. I use Mac. The script uses ‘desktop’ and ‘documents’ near the end of the script. I cannot find how to change these to a new field (PATH), where the new path could be written into. Any help is welcome!

  6. Any chance of uploading a Demo File that allows us to define the path in a field? I just can’t seem to get it. Running on MAC

    1. Hi Frank, for the OSX version, the applescript is creating the path, not filemaker. I’m using applescript’s “path to desktop folder” function or “path to documents folder” function to get the path, which is set as a variable in the applescript defined as “theOutputFolderPath”. I’m not an applescript expert, so I’m not sure how to construct a path that’s not to the desktop or the documents folder; I would have to look it up. Let me know if you don’t find a solution and I will do some digging.

  7. Very nice blog post and demo file…

    Here is one way to discover a folder path…

    [begin excerpt]
    set a_folder_path_HFS to choose folder — or choose file
    set a_folder_path_HFS to a_folder_path_HFS as string
    set the clipboard to a_folder_path_HFS

    display dialog “the path to the folder is on the clipboard.” buttons “OK” giving up after 3 — seconds
    [end excerpt]

    How to set color/label index and type coercion here:



    1. Makah Encarnacao

      Hi Dom,
      Try saving the file as a .zip file when you download it. Then unzip the file and it should work. Apologizes for the confusion.


  8. This is a great tool, is there a way to modify the applescript and windows script to go to a file path, instead of just the desktop or documents? I’d like to create new folders within our Dropbox, which is always in a users home directory on Mac, but on Windows it can vary depending on OS version.

    1. Makah Encarnacao

      Hi Tyler, thanks for the feedback. I haven’t actually tried it myself, but if you look at Tony White’s comment above, he does provide some tips on how to set the path to something other than documents/desktop for AppleScript. According to this article about applescript, (https://discussions.apple.com/thread/3809986), it looks like you can change the path to “Mac HD:Users::Dropbox” where is the computer’s user name.

      For Windows, see my comment above in reply to David where I help him with the music folder. If the path varies, you can try using the Get Directory () script step to have the user select the path. This script step also has a “Allow Create Folders” option so they can create new folders from this dialog as well. Hope that helps!

  9. Hey Everyone. I noticed a lot of people are asking about more custom file paths. I modified the wonderful script that Makah created to do this. Sadly I can’t host the file here (if anyone at Soliant Consulting would like to host it, I can email it to them), but all it takes is modifying a few things. All the below assumes that $path contains the path and $name contains the folder name:

    Windows (largely unchanged – mainly took out the sub folder):
    Set Variable [$windowPath] ; Value: Substitute ( “/” & $path; [“//”; “”]; [“/”; “\\”])
    Send Event [ “” ; “aevt” ; “odoc” ; “cmd.exe /C MKDIR ” & Quote( $windowsPath & $name & “\\”)]

    Set Variable [$appleScriptPath ; Value: Let (
    ~path = Substitute ( $path ; “/” ; “:”);
    ~cutLeft = GetAsNumber ( Left ( ~path ; 1 ) = “:” );
    ~cutRight = GetAsNumber ( Right ( ~path ; 1 ) = “:” )

    Middle ( ~path ; 1 + ~cutLeft ; Length ( ~path ) – ~cutLeft – ~cutRight )

    ) ]
    Perform AppleScript [ “set folderPath to ” & Quote ( $appleScriptPath ) &¶&
    “set folderName to ” & Quote( $name) &¶&

    “tell application ” & Quote ( “Finder” ) &¶&
    ” if (exists folder (folderPath & folderName as string)) = false then make new folder at folderPath with properties {name:folderName} ” &¶&
    “end tell”

    Sorry since that’s a little confusing to read. If anyone wants a copy of the file, feel free to email me at paul@peak14.solutions.

    1. Makah Encarnacao

      Hi Paul,
      Thank you for your comment and for sending me a copy of your updated file! I have updated the blog post to have a direct download link to your file. Thanks again!

  10. Thanks so much for this. It’s wonderful.

    It is making me delve into understanding AppleScript as I am trying to create a series of folders, sub folders and sub-sub folders and I *think* I’m getting somewhere…

Leave a Comment

Your email address will not be published. Required fields are marked *