Jump to content
Server Maintenance This Week. ×

Detect "File cannot be found" container


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

Recommended Posts

I calculate a path (through a calculation field) that is displayed in a container.  If the referenced file is not present, the container field displays the text "The file cannot be found."  

 

Is there anyway to create a calculation field to note if that file is present.  In other words, is there anyway to have another calculation field read the container field to note that the file isn't present?

 

I have tried "isempty", but the record with an invalid reference is not considered empty.

I have tried "patterncount" for the word "cannot", but it seems that Filemaker doesn't consider the error message "The file cannot be found" as text in the container field.

I can't find anyway to capture that the reference is invalid.  It seems like it should be possible, since the container field already contains the information I'm looking for, but I can't see how to capture it.

 

Any help would be appreciated.  

Link to comment
Share on other sites

Oddly enough, I just tried this.  Unfortunately, getastext supplies only the file path.  I can't seem to find any way to distinguish between a container that shows an icon (the referenced file is present) and a container that displays "The file cannot be found...."

 

Thank you for the thought, all ideas are appreciated.

Link to comment
Share on other sites

Have you stepped through your script using the Script Debugger, and looked to see what error was thrown when this occurs?  You might then be able to add a Get(LastError) step to your script to trap for the error.

Link to comment
Share on other sites

I am not looking to make this determination through a script, but rather through a field calculation.  I'd like a calculation field to show whether or not a file is present.  I can't find a function that can discriminate between a container field with a reference where a file is present and a reference to a file that is not present.  The odd thing is that the container field itself shows a difference (one shows an icon of the file, the other says "The file cannot be found.").  So filemaker can see a difference, but there seems to be no way to capture the difference in a calculation.

Thank you-

Link to comment
Share on other sites

  • 4 years later...
  • Newbies

I know I'm replying to a post nearly 5 years old, but I'm looking for a solution to this problem as well. IsEmpty(field) doesn't recognize when a link to a file is broken in a container field. I'd like another field to calculate when thumbnail images and/or quicktime videos go missing so I don't have to scan through the table for gaps. Does anyone know how to do this?

Link to comment
Share on other sites

I'm assuming that you are using referenced containers (where the content has been inserted by reference only  - as opposed to an embedded or remote container type of content)?

If so you can use the "Get File Exists" script step and give the last line of the container value, which is the path to the file.

I wouldn't try to find a calculated field way of doing this, a script will do just fine and can produce a found set of records that you need to look at.

Link to comment
Share on other sites

  • Newbies

Thanks, Wim!  Your assumption is correct, I'm using referenced containers in an effort to control the file size of the database.

I tried to create a button to activate that step, but it looks like that function only works in v18, while I'm stuck with v17 for now. Previously I was using v13 with this calculation field: (If (IsEmpty(QT_movie) ; "Missing" ; "")). It worked well as I could easily isolate the quicktimes I needed to import or re-import if the link became broken.

I've now put the quicktimes into their own table, so it's easy to batch delete and re-import a set of quicktimes when needed. Although I wouldn't have to pull them all offline if I could find a way to easily isolate the missing quicktimes again.

Do you have a v17 option? Thanks again for your input!

Link to comment
Share on other sites

  • 6 months later...
  • 2 months later...
  • Newbies
On 12/12/2019 at 2:40 AM, MattS said:

I'd like another field to calculate when thumbnail images and/or quicktime videos go missing so I don't have to scan through the table for gaps.
[...]
Do you have a v17 option? Thanks again for your input!

I only have v14 so the work around I have used is this:

Let ( 
result = /* your file path calculation here */
;
If( Length ( Base64Encode ( result ) ) > 100 ; result ; "drag picture to insert" ))

Since you said you wanted an easy way to find files without pictures, just create another field with the calculation:

If( Length ( Base64Encode ( yourContainerField ) ) > 100 ; "yes" ; "no" ))

And search where that field = "no".

I dont know too much about the base64encode, but basically if you dont have a file Base64Encode gives you a fairly short string (hence > 100) while valid files generally gives you a super long string. 

Link to comment
Share on other sites

  • 4 months later...

bsin's calculation actually works well except that with the images I'm using the number need to be slightly higher than 100. Using a "not found" image called "9.jpg" (five characters long) the character count for Base64Encode was 106; for image 10.jpg (6 characters long) it was 110. Longer image files names would likely be higher but not by much. Since the character length almost any image is going to be, depending on the image size, hundreds to hundreds of thousands of encoded characters, a slightly higher number - I'm using 200 - seems to work fine.

Link to comment
Share on other sites

I don't think you need to depend on any number. If the file doesn't exists, then Base64Encode ( ContainerField ) will encode the path - so decoding it back should return the path. IOW, the expression:

Base64Decode ( Base64Encode ( ContainerField ) ) ≠ GetAsText ( ContainerField )

returns true when the referenced file exists, false otherwise.

 

Link to comment
Share on other sites

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