Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 7093 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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...

Posted

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.

Posted

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.

Posted

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...

Posted

Hi Bob,

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

Posted

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

Posted

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

Posted

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...

Posted

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...

This topic is 7093 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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