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

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

Recommended Posts

Posted

I have a problem with printing from an FMP script to .ps or .pdf because FMP doesn't remember the name of the output file. To get around this, I have been looking at the archives of this list and someone mentioned what is my script below, but I cannot get it to work. I get a message something like: "Finder got an error: Can't set file "PDF:Tool Bar Dock.pdf" to "Annual data-1.pdf""

How can I get my file renamed? I have to generate five .pdfs per record and each one is attached to separate auto email from FileMaker and for this exact file names are essential. Here is my script:

set theKnownPath to "PDF:Tool Bar Dock.pdf"

(--this is FileMaker's usual generic file name)

tell application "FileMaker Developer" to set the newName to cell "Extract-1 Applescript Name" of current record

tell application "Finder" to set the name of file theKnownPath to newName & ".pdf"

Thanks for any help

Oz

Posted

Well, it seems to be kind of a sneaky workaround. When you are printing to a file, the print driver takes the title of the frontmost window and appends ".ps" or ".pdf" to it. It just so happens that when Filemaker is the active application, and you are displaying the Filemaker toolbar (the one at the top of the screen) it will be the frontmost window, and its title (although you can't see it) is "ToolBarDoc." So the default title will be "ToolBarDoc.ps" etc., unless the toolbar is hidden, in which case the frontmost window will be your active database file (example, "MyDbase.fp5"). In this case the default file will be your database file name with ".pdf" or ".ps" appended to it. So, for your script to work, you would need to make sure that the tool bar is visible before running. There is no way to force it on in a script, but you can force it off. So, you could possibly try something like forcing the toolbar off with the "Allow ToolBars [off]" script step before you perform the applescript, and replace the first step of your applescript with:

set theKnownPath to "PDF:MyDatabaseName.fp5.pdf"

where MyDatabaseName.fp5 is the actual name of your database file.

Posted

It doesn't look like you're telling the Finder the full path name of the file. Try using something like "Macintosh HD:PDF:In:Annual PQ.ps" or whatever the full path is.

Posted

Tried changing the path to MacHD:Desktop Folder:PDF, etc. but that doesn't work either.

Would it be possible to rename just the bit before the .ps (or .pdf)? Would it make any difference?

Thanks for your help

Posted

I'm guessing that what is happening is an incompatibility between object types. It could be that the Finder doesn't recognize theKnownPath to be a file, though it should be obvious. You could try:

tell application "Finder" to set (name of file theKnownPath) to (newName & ".pdf") as text

The best way to debug it is to do this in the applescript editor, and make sure that the file you want to rename actually exists in the specified directory. In other words, eliminate as many variables as possible. Then start trying lots of variations on the syntax. It is Applescript after all.

smile.gif

Posted

Coincidentally someone else wrote a solution for someone else on another list, and this works:

Set commonFolderPath to "Folder1:Folder2:"

Copy cell "FullName" of current record to fullname

Copy cell "SKU" of current record to SKU

Copy SKU & ".jpg" to SKU

Set FullPath to commonFolderPath & FullName

Tell application "Finder"

Set name of file FullPath to SKU

End tell

Thanks for everyone who tried to help me with my problem.

Kind regards

Oz

This topic is 7951 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.