Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

"Save A Copy As" with date/time added to filename?

Featured Replies

Is it possible to create a script to use the "Save A Copy As" function but add the current date and time to the backup file filename? I want the user to backup when opening the database application and keep multiple copies of the backup file. I would like to somehow limit the backups to 7 and then start overwriting the files using FileMaker Pro7 V3 features only.

I tried: Save a Copy as["myfilename`Date + %m%d%y%h%m`.fm7";copy] but the date function doesn't convert to the current date/time.

Bob...

Hi Bob,

The Save a Copy As... script command does not of itself give you the option to dynamically specify the file name. However you might consider having your script create a copy (at a fixed path and with a fixed name) and then subsequently have the script rename the saved copy.

The renaming trick can be achieved by using VBScript (on windows, via the 'Send Event[ ] script command) or AppleScript (on MacOS, using the Perfomr Applescript[ ] script command) - or alternatively, if you are not familiar with the scripting language on your OS, you might consider using a third party plug-in. There are several available which do this, but perhaps the best known is 'Troi File' from Troi Automatisering.

I don't think it is possible to add a calculated filename into the Save A Copy As function. But you can fudge it in windows by saving the file to a named copy and then renaming it.

Save a Copy as["Copy.fp7";copy]

SendEvent["aevt";"odoc";"Cmd /K " & "ren copy.fp7" & " copy" & Day(Get(CurrentDate)) & "-" & Month(Get(CurrentDate)) & "-" & Year(Get(CurrentDate)) & "-" & Hour(Get(CurrentTime)) & "-" & Minute(Get(CurrentTime)) & "-" & Seconds(Get(CurrentTime)) & ".fp7"

The Send Event opens a command box and then renames the file copy.fp7 to copy followed by date and time.fp7.

This command box stays open so that you can check that the renaming has taken place properly. Once it is running properly replace the /K by /C and the box will automatically close. For this example I have used "-" as a separator in the date and time. Pick your own but make sure they do not clash with windows file naming exclusions.

  • Author

Thank you Ray for the reply. I was afraid that was the case. You suggest having my script "subsequently rename the saved copy". That would be good fix if I knew how to remane the saved copy. Would you help me out here with the code?

Bob...

Hi Bob,

Your sidebar says you are on XP, and that being the case, it looks as though SlimJim has anticipated you... wink.gif

  • Author

Thanks SlimJim just got your reply. I'll give it a try.

Bob...

  • Author

SlimJim,

I'm sorry but I tried everything I can think of but I can't seem to get the script to work. It does execute but the file name doesn't change. I have attached the database for reference. I truncated some of the steps in the "StartupBackup" script to help troubleshoot but I don't know what to look for. The command box doesn't open so I can't check the file renaming as you suggest.

If it askes you for a password its password.

Bob...

Copy.fp7.zip

OK Bob I finally worked out that your user account might be called Bob (sorry I'm a bit thick at times). I found the problem. The stuff at the end of the SendEvent is a calculation, not text. I have changed it and will repost (I have had to change the name from Copy to Backup because your sample was called Copy and FMP couldn't do the script on the current file.

Copy.zip

  • Author

Yes that worked as advertised. I couldn't get to work at all as a calculation. What did I do wrong. And thanks again for your help.

Bob...

  • Author

SlimJim...

This is my summary of your "Backup file Name with Date/Time Appended Script".

Description: A Backup Script that renames the backup file and adds current date and time to backup file name.

Script name: BackupStartUp

Save a Copy as ["Backup.fp7"; Copy]

Send Event

(options, select "Calculation" specify the following)

"Cmd /K " & "ren Backup.fp7" & " Backup" &"-" & Day(Get(CurrentDate)) & "-" & Month(Get(CurrentDate)) & "-" & Year(Get(CurrentDate)) & "-" & Hour(Get(CurrentTime)) & "-" & Minute(Get(CurrentTime)) & "-" & Seconds(Get(CurrentTime)) & ".fp7"

(Note 1: the "aevt"; "odoc" parameters are specified automatically for you by the Send Event function, don't try to add them yourself)

(Note 2: The Send Event opens a command box and then renames the file copy.fp7 to copy followed by date and time.fp7.This command box stays open so that you can check that the renaming has taken place properly. Once it is running properly replace the /K by /C and the box will automatically close. For this example I have used "-" as a separator in the date and time. Pick your own but make sure they do not clash with windows file naming exclusions.

Bob...

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.