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

file saving with different names with a script

Featured Replies

  • Newbies

How can I give different names to an exportfile when I use a script?

(Every week I want to sent a report with the name "weekverslag<todays date>"

AppleScript ?

It looks like you're on a Mac, if so AppleScript will do the job for you.

Paste this into the Script Editor:

set a to (current date) as string

set b to "weekverslag " & word 2 of a & " " & word 3 of a & ", " & word 4 of a

tell application "Finder"

set name of file "report" of desktop to b

end tell

Now save the script as an application, or Applet as they say.

Now just script in FileMaker the export of a file named "report" to the desktop, then have the script Send Apple Event (Open Application) to the Applet.

  • Author
  • Newbies

How can I give different names to an exportfile when I use a script?

(Every week I want to sent a report with the name "weekverslag<todays date>"

I work with Filemaker 5.5 developer and windows 98 and 2000

Please change your icon, Andre. You're welcome.

  • 2 months later...

Thanks! Could you tell me how to use applescript to use data from a FMPro database field as part of the title?? Really appreciate the help!

  • 1 year later...
  • Newbies

Realizing this is an old thread, but I am trying to understand how to solv a similar problem...

I need Filemaker to export one record or a set of records in to a textfile (html) and I can do that easily with the internal scripts. But Ideal would be to be able to set the name of the output file from inside Filemaker.

I have seen a Troi plugin that will do the job, but they are both expensive and somewhat over qualified for this relatively simple task.

I know I have seen an applescript somewhere that could be triggered from inside FMP, and look inside a dedicated folder where FMP just dumped the exported file, rename the file to a name from inside FMP. Best would be if the applescript can be "attached" to the FMP, and not live like an applet or script outside... But any and all suggestions are more than welcome!

So can anyone give me a suggestion on how this script should look like and how I trigger it from Filemaker.

TIA

Mike

Hi Mike,

Use "Perform Applescript" from within a FileMaker script.

An example of what part of the Applescript could look like:

tell app "FileMaker Pro"

set a_variable to get data cell "fm_field" of record 1

end tell

This gets the FileMaker cell data into Applescript which can then change the file name based on this information.

If you need more detail, let me know.

Cheers, Peter.

  • Newbies

Hi and thanks a lot Peter,

I would really appreciate some more help...

So to get this to work, I need to specify in the applescript name and path of the folder where the exported file ends up?

The field in FMP that hold the name of the output file, is named "filename"

Anything els I have to think of?

Thanks in advance!!

Mike

Once you have exported your file, add the following AppleScript (Perform AppleScript).

set startup_disk to path to startup disk as string

set export_file to startup_disk & "fm_export_file"

tell application "Finder"

if file export_file exists then

tell application "FileMaker Pro"

set a_variable to get data cell "filename" of record 1

end tell

set name of file export_file to a_variable

end if

end tell

What this AS does is sets export_file to the generic file that was exported from FileMaker. If the file exists, AS then sets a_variable to whatever is in the field filename of the open FM database. It then uses this information to rename the exported file.

You could add error checking to the above to cover possible problems.

Cheers, Peter.

Peterh said:

Once you have exported your file, add the following AppleScript (Perform AppleScript).

set startup_disk to path to startup disk as string

set export_file to startup_disk & "fm_export_file"

tell application "Finder"

if file export_file exists then

tell application "FileMaker Pro"

set a_variable to get data cell "filename" of record 1

end tell

set name of file export_file to a_variable

end if

end tell

There is an important error in this script.

This statement:

set a_variable to get data cell "filename" of record 1

Should be changed to refer to the current record:

set a_variable to get data cell "filename" of current record

If you don't make this change, you could be on record 33 and get filename from record 1.

Good point, thanks for picking that up (hey, it would have worked for globals though blush.gif )

Cheers, Peter

  • Newbies

Thanks all, this forum is a gold mine!!

Create an account or sign in to comment

Important Information

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

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.