10 Replies Latest reply on Dec 4, 2014 12:09 PM by taylorsharpe

    Create folder thru scripting

    Nerico

      I do a lot of importing and exporting of spreadsheets from my database and end up creating a lot of "throw-away" files. In order to keep from junking-up my desktop, I created a temp folder to put these files in. I'm writing script steps that find or dump files to and from this folder. But now other uses are going to start running these scripts, and they will not have the corresponding folder on their desktop. Is there a way for me to script for the creation of the folder so I don't have to rely on each user having to mannually create it and not knowing how to name it properly?

       

      thanks.

        • 1. Re: Create folder thru scripting
          TomHays

          Perhaps you should use the built-in temp folder which you can locate via Get(TemporaryPath).

           

          -Tom

          • 2. Re: Create folder thru scripting
            Nerico

            Although the files are somewhat "throw-away", they do need to be stored as regular "permanent" files (until the user is done with them and can trash them at their leisure) and they have to be easily accessible.   I have not used the built-in temp folder but I think the files get automatically deleted.

            • 3. Re: Create folder thru scripting
              jormond

              If you can use something that is existing, as Tom suggested, that would work well.  There are a couple reasons you may not want to use that approach, but likely that will work for you.

               

              I wrote a brief blog post about creating a folder on Windows.  There are a numbers of ways/options to do this on Mac or Windows, but I can put my finger on them at the moment.  If you need them, post back and I will go hunt for some of the other posts/articles I've run across.

               

              http://fmrift.wordpress.com/2010/02/03/creating-a-folder-from-filemaker-windows/

              • 4. Re: Create folder thru scripting
                barenose

                Hi Josh,

                 

                I would like to know how to do this on a Mac. I've used AppleScript a little bit before, but am certainly not a pro at it. If you can find those other posts you mentioned, I would be interested.

                 

                            All the best,

                 

                JB

                • 5. Re: Create folder thru scripting
                  Stephen Huston

                  Another EXISTING place you can set in a path using the Get functions, is the Documents folder. Works just like the desktop location, but less obvious to the average user.

                   

                  In fact, with both the Desktop and Documents usable via scripting and calculated paths, you could even provide a scripted dialog to ask your user which place to put the file when saving it, and then set the appropriate path to either Desktop or Dcouments/MyDocuments based on their response to the dialog.

                  • 6. Re: Create folder thru scripting
                    sporobolus

                    on 2012-05-31 17:18 barenose wrote

                    I would like to know how to do this on a Mac. I've used AppleScript a little bit before, but am certainly not a pro at it.

                     

                    basically like this, tweak as desired:

                     

                    set parent_folder to path to desktop folder as alias
                    set my_folder_name to "whatever it should be called"
                    set my_folder_path to (parent_folder as string) & ":" & my_folder_name
                    tell application "Finder"
                       if not (exists folder my_folder_name of parent_folder) then
                         make new folder at parent_folder with properties {name:my_folder_name}
                       end if
                    end tell
                    

                     

                    • 7. Re: Create folder thru scripting
                      taylorsharpe

                      There are several file management plugins that will work for you just fine.  If you don't mind a little tinkering, 360 Works' ScriptMaster plugin is both free and can create and erase files and folders in a script step.  I use it all the time for files I download, import, then erase.  Also, the desktop is not a great place to keep folders.  Creating a temp folders inside of My Documents or Documents is a better idea. 

                       

                      One thing I like about ScriptMaster is that it can get the contents of a folder and I can search to see if a file with a particular type has been downloaded.  If it exists, then I import it and then erase it.  Or there are many other things you can do.  Just a little plug for this free plugin. 

                      • 8. Re: Create folder thru scripting
                        barenose

                        Thanks Taylor!

                         

                        That works like a charm!

                         

                                    All the best,

                         

                        JB

                        • 9. Re: Create folder thru scripting
                          MallieWilliams

                          Tayloer, Can you give an example of how to modify the script in script Master for the Create Folder? I tried to modify it and it's not working.

                          • 10. Re: Create folder thru scripting
                            taylorsharpe

                            What you mind find easier that a lot of us use now is the Base Elements plugin from Goya.  It has all of the file manipulations functions included and the plugin license is free.  Also, I find that FileMaker loads a lot faster using BaseElements instead of ScriptMaster plus a script to create the functions.  So unless I need to make something very unique with say the groovy programming language, I'm not using ScriptMaster much anymore with alternatives like BaseElements.  ScriptMaster is very powerful, but complicated and I have found to be slow for some of my simple needs. 

                             

                            Actually, if I need something complicated, usually I can find it in the Monkey Bread Software plugin.  It is not free like Base Elements and ScriptMaster, but Monkey Bread Software has 2400+ functions including the entire CURL library, file manipulations, graphic manipulation, encryptions and so much I can't even think of. 

                             

                            If you want free, then try Base Elements is my suggestion.  But if you do just need a simple help with 360Works for creating a folder, the 360Works people are very friendly and helpful.