I wrote a filemaker pro 7 database program for my wifes practice. I wanted to create backups of the database for each time she changed something. Ideally I would keep only the last 2 months of backups and delete the rest. Since you can only make a file “Database Copy.fp7” from within Filemaker pro 7, I thought I would write an Applescript that could be called from within filemaker. I would set filemaker pro to call a filemaker script at shut down that would first make a generic backup of the database “Database Copy.fp7” in a backup folder. Then the filemaker pro script would perform an applescript to rename the file with a date and timestamp. I would then have the applescript delete all the files in the backup folder that were older than 2 months. As another wrinkle since the database is used on a desktop and laptop computer that are synchronized I didn’t want the Applescript to delete files created on the desktop when run on the Laptop and vis a versa. My solution was to have the Filemaker script determine if the database was being run on the desktop or the Laptop and run the Applescript designed for each computer. The major difference was that the Applescript would add “L-” before the database name if on the laptop or “D-” before the name if on the desktop.
I am a novice at applescript but from searching this site I came up with the following is the Applescript for the laptop:
tell application “Finder”
set somedate to current date
set shortsomedate to short date string of somedate
set hrsomedate to hours of somedate as number
set minsomedate to minutes of somedate as number
set secsomedate to seconds of somedate as number
set the name of file “Macintosh HD:Users:AllynLaptop:Documents:Allyn Clients:clientbackups:ClientDatabase Copy.fp7” to “L-ClientDatabaseBKUP” & shortsomedate & " " & hrsomedate & “-” & minsomedate & “-” & secsomedate & “.fp7”
set thefolder to alias “/Users/AllynLaptop/Documents/Allyn Clients/clientbackups”
delete (items of thefolder whose creation date < ((current date) - (60 * days)) and name contains “L-”)
I tested this script and it seems to work. Am I missing any potential complications. How can I capture possible errors like no file existing to change the name to.
Also this file works as a stand alone script, but when run from within a Filemaker script I get a out of memory error???
Any help suggestions would be much appreciated
Model: iMac G4 and ibook G4
Browser: Safari 417.9.2
Operating System: Mac OS X (10.4)