Jump to content

file saving with different names with a script


agmk
 Share

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

Recommended Posts

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.

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

  • 2 months later...
  • 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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 6621 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
 Share

×
×
  • Create New...

Important Information

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