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

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

Recommended Posts

  • Newbies
Posted

Hi!

(How) is it possible, to rename a file within a container field?

Currently, we are exporting the file to a calculated path and desired filename and import it again with a script.

But there must be a better way. Is this possible with the ScriptMaster plug-in? (or any other plug-in)?

Thank you,

Bernhard

Posted

There is an object ScriptMaster creates and has access to (fmpro) that can be used to accomplish this.

You'll use two input parameters ("fully qualified original container field name" and "new filename"). The code is extremely simple:

return fmpro.getAsContainer(fmpro.getContainerStream(fieldName), fileName);

Once you have created the function you'll want to call it using a Set Field step on the output container field. The result of the function is FM Binary and the filename. You can add use the ScriptMaster sample file to test this.

Posted

This is great! I was looking for a solution just like this since I found yesterday I could import binary data from SQL server to filemaker container fields via OBDC. Here's my post from yesterday.

Importing varbinary data into container from SQL server

All the varbinary fields I imported have the name "Untitled.dat" but the original filename and extension are imported into other text fields. So if I can use Scriptmaster, I should be able to rename all the container contents to their correct names. The reason I want to do this is to avoid just the export import route is that my file is 800 GB and there are probably 250,000 binary files.

Also, it seems that if I want to use 360Works scribe to extract text contents from all the supported files, they will have to be renamed with the correct extension so scribe will recognize them.

Posted

Since I'm new to scriptMaster, I'm wondering if I could get some help adding this script to the file. Here is what I've done and the error I received upon trying to run it in a test file.

The final error when trying to do the set field on the container was "com.prosc.fmkit.FmCalculationException: 102"

I have attached screenshots of how I added the function and called it in the attachment.

screenshots.pdf

Posted

The first parameter should be "renamecontainer::container", in quotes, i.e. the fully qualified container name, rather than renamecontainer::container which is a reference to the container contents..

Posted

Thank you so much! I was looking all over for documentation on the GetAsContainer() function to no avail, but that now makes sense based on wbasham's original reply. Works like a charm now.

Posted

This module hasn't actually been released in the plugin so there is no documentation yet. It is fairly simple though and will likely be added to the next version of ScriptMaster.

  • 1 year later...
Posted

Can this be done natively now in FMP 12?

 

I am running FM Server 12 Advanced. I have a container field with it's images being stored externally in a folder on the same server. I have a text field which contains the new name that I would like to apply to each photo. Can I rename the files from a client running on a different computer?

  • 2 months later...
Posted

This technique is excellent and exactly what I need for a database where I have to insert a file into a container field and rename it based on the record identifier and a few other criteria. The only problem I'm seeing is with PDFs the renamed file in the container field displays as "The file cannot be displayed: filename.pdf". Every other file type I've tried (doc, docx, gif, xls, jpg, etc) renders the same before and after the file name change but PDFs do not. The file itself is fine and if I export and reinsert the file it renders correctly but I'd much rather not have to export and re-insert the file every single time I encounter a PDF. This is with FIleMaker Pro 11.0v4 running on Mac OS X 10.6.8.

 

So what's specific to PDFs which causes this problem and can it be fixed?

 

Thanks.

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