4 Replies Latest reply on Dec 21, 2015 9:48 AM by Mike Duncan

    Save  copy of file and add current date?

    jackmac

      Hi all,

       

      I have written a simple backup for one of my FileMaker systems. It saves a copy of the file to a specified folder and overwrites the previous if required.

       

      I would like to keep all copies if possible. Is there any way I can save a c opt of the file and add today's date to the filename? That would make it unique each time and would mean I had a backup each day.

       

      TIA

       

      Jack

        • 1. Re: Save  copy of file and add current date?
          jackmac

          I'm using FileMaker Pro Adv 14 on Windows 7

          • 2. Re: Save  copy of file and add current date?
            Mike Duncan

            You can set a variable to use when saving the file. Personally, I like to use a date format that sorts as text. Here's a calc that does that:

             

            "file_name_" &

            Let ( [

                   Dn = Get ( CurrentDate ) ;

                   date_string = Year(Dn)*10^4 + Month(Dn)*100 + Day(Dn) ;

                   Hr = Get ( CurrentTime ) ;

                   time_string = Hour ( Hr )*10^4 + Minute( Hr )*100 + Seconds( Hr )

                    ] ;

             

            "_d" & date_string & "t" & time_string

             

            ) & ".fmp12"

             

             

            Of course, you will also need a way to clear out old backups automatically if you don't intend on doing it manually. That's a good reason to use FM Server, as that is a feature of the backup routine in server.

            • 3. Re: Save  copy of file and add current date?
              jackmac

              Thanks Mike.  I must be having a d/a day as I can't get it to work.. sorry.  I can see the logic and it makes perfect sense, it's the actual scripting that's catching me out.

               

              I'm using 'Save a copy as' and the window I get when I choose the output file I input:

               

              file:datacopy.fmp12

               

              Where should I be inputting your solution? That's where I'm lost.

               

              TIA

               

              Jack

              • 4. Re: Save  copy of file and add current date?
                Mike Duncan

                You need a step where you set the variable, say for example your variable is named $this.path and you set the value like I outlined above, but with the full, valid path as needed.

                 

                Then in the "Save a copy as" step where you specify the file, you enter $this.path as the only value listed.

                 

                Hope this helps

                Mike