Jump to content

Rename file in container field


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

Recommended Posts

  • Newbies

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...

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?

Link to comment
Share on other sites

  • 2 months later...

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.

Link to comment
Share on other sites

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