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

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

Recommended Posts

Posted

Hello

I am a newbie that has made a very silly mistake and is hoping to get around it. In a photo db I created sometime ago, I have numerous containers in a sheet that contain low res pix that I have imported. Over time this db has become far larger than first designed so I am looking for a way to get FM to automatically look at each container contents name i.e. photo and search my HD for the original before replacing the FM container with the file location. In short:

1. Establish the file name in the container

2. search the HD for the file

3. If a dupe found, ask what to do.

3. If not, replace the container contents with the file location.

Writing it like that is easy for me. It is just the script writing part that I find unfathomable.

Thank you to you all for all your help.

Posted

There is a Find command built in to Unix. You can combine that with AppleScript's choose from list command to get much what you want. The example has no error checking, but it works. It is currently looking in the user's Home folder. It would be much much faster if you narrowed that down a bit, with something like 'path to pictures folder' instead.

Container_Insert_wFind.zip

Posted

Fenton

Thank you very, very much. As I mentioned before, I am just a newbie and so I am struggling a little (actually alot). So here it goes with the questions.

1. I have tried to change the Apple script to start looking at a specific folder but I cannot find a way to add the file path. I have added

set theFolder to (quoted form of (text 1 thru -2 of (POSIX path of /Volmues/PM WORLD/WORK/PMWORLD DECORS/ARCHIVE DECORS/))))

but applescript says

SYNTAX ERROR

Expected expression but found “/”.

when i take / out , I get

Expected “, ” but found identifier.

2; When I run the script as you sent it, its stops at:

set theChoice to POSIX file (first paragraph of result)

3. This is the first ludite question: You have a file name and a container. In my system, I have no file name associated to the container, except when I export it, then it appears. Is there a way to extract from the container the file name? (I attach my "fantastic"(??) DB)

4. The second luddite question is: can I integrate your system into the master file or is it only through a portal?

Many thanks

Posted (edited)

> set theFolder to (quoted form of (text 1 thru -2 of (POSIX path of /Volmues/PM WORLD/WORK/PMWORLD DECORS/ARCHIVE DECORS/))))

The AppleScript command: POSIX path of

converts a an older Mac path (with the colons, etc.) to the new Unix path, which is similar to what you've got above.

The AppleScript command: quoted form of

escapes spaces, etc. in the text, which Unix commands don't like; you can use single quotes also.

text 1 thru -2 is just a way to remove the last slash. Which it turns out is not even necessary. I copied that from someone's earlier example.

So, what you're trying to do above is unnecessary. If you know the correct Unix path, then just use it. Example:

'/Users/fej/Documents/FileMaker/My_FM/AS/CONTAINER Images PDFs/Container Insert wFind/'

another (quotes aren't needed, no spaces)}:|

/Volumes/manavesh/Public/

Or if you know the correct Mac path, use that. Same result:

POSIX path of "Macintosh HD:Users:fej:Documents:FileMaker:My_FM:AS:CONTAINER Images PDFs:Container Insert wFind:"

> 2; When I run the script as you sent it, its stops at:

set theChoice to POSIX file (first paragraph of result)

Jaguar's AppleScript does not support "first paragraph"? It is unnecessary also. Try this:

set theChoice to POSIX file to result

Or maybe it just didn't find it. As I said, I didn't put any error-checking in the script; just the basics. This new example tells you it's not found at all.

Other lines of the AppleScript also have "paragraphs", and I don't know when "choose from list" was implemented in AppleScript. Basically if you run a really old OS, you're going to have problems using other's examples. I'm not the kind of AppleScript expert that knows (or can remember) the history of when things were updated, nor older ways to do the same thing. I take the easiest route :-]

> 3. This is the first ludite question: You have a file name and a container. In my system, I have no file name associated to the container, except when I export it, then it appears. Is there a way to extract from the container the file name? (I attach my "fantastic"(??) DB)

So, what is this about, exporting the image? You'd need to rename it with the name in the database. Which does have a file name, else how were we doing the Find routine above?

But, in any case, I've answered this question fairly recently here. I'll do so again, but I don't have time right this moment.

> 4. The second luddite question is: can I integrate your system into the master file or is it only through a portal?

My example doesn't even have a portal. It's just a simple example file, showing the AppleScript/Unix method to Find a file. I don't see what "portal" has to do with it. So, the quick answer is: if the file name is in the portal, use a button to set it into a global field, which should be on the layout for AppleScript to see it (can be hidden); or specified by table occurrence name: cell "_g_filename" of table "ContainerInsert"

Notice that a global field does not need the 'current record' reference.

Container_Insert_wFind.zip

Edited by Guest
quoted form of
Posted

Many many thanks.

Concerning the file name. What was being done was that in an image container, I have been importing the pix using the ctrl key. The image is associated to the sheet by a serial number and not by the file name. I don't search the images, I search info that held in the sheet that concerns the images. The only way for the moment that I can find the file name, is to export it. I presume, hidden in the file is the name. The question is how to extract it.

Posted (edited)

GetAsText ( Container field ), calculation, result Text

How you parse it out depends on whether it's an embedded or referenced image (different number of lines and info).

Edited by Guest
Posted

Is it possible to parse an embedded image file? A tech at filemaker france said that it was not ... but do not beleive him. (Probably I don't want to believe him)

Posted

Say what? GetAsText ( Container ) of an embedded image returns the name; at least it does for me. It's easy enough to try. I don't know whether that's what you mean.

Posted

I was under the impression that he had original files which were not "low res"; so he wanted to go find those originals. But, if the originals are the same as embedded container ones, then you could just export the embedded ones, then import again "as reference." That is pretty easy, using script variables, as comment did in his example. But, as is so often the case, no one can accurately solve a problem, especially to do with images, containers and file paths, unless we know exactly what it is. It was kind of fun to "find" a file with FileMaker though :-]

Posted

Thank you all for your time. My DB has images that were imported as pictures into containers. When I import them, I do not add their file name to the DB. So Fenton is right in presuming that the first thing to do is to parse the file name out of the container. I have not been able to do that as yet, but I am endeavouring. That file name should correspond to an original file on my HD, that I subsequently want to replace as a link in the original image container. The export and reimport route could do, but the orginals are arranged in specials files, therefore I would prefer to avoid it. I presume in parsing the file name from the embedded file, I have to create a text field to contain it in?

Posted

You have to define a calculation field (result is Text) = YourContainerFieldName. However, since your images are embedded, you will get ONLY the file NAME - not the PATH to the original file.

So this is only the first step: you know the name of the file, and now you have to find it (either manually, or by using Applescript - Filemaker cannot do this for you). If you find more than one file with the same name, you will need to decide which one is the correct one.

OTOH, if you KNOW where the original files are, you can avoid the search. Instead, you can type the path into a text field, add the filename (by calculation) and use the result to point to the correct file (see my last post in the other thread).

Posted

Amazing. after reading and playing about with the calculations Fentons, calculation has given me file names. Thank you

Now I am back on the apple script, but getting nowhere. From what I understand (which basically nothing) here is what I have remanaged. My problem is that I do not which parts are change and those I don't.

-- set theFolder to (quoted form of (POSIX path of (path to home folder)))

set theFolder to (POSIX path of "DD:Users:christ:PRIVATE:PMWORLD_DECORS:ARCHIVE_DECORS")

tell application "FileMaker Pro Advanced"

set fmName to cell "ContainerFieldName" of current record

set theName to quoted form of fmName

end tell

try

set theFiles to (do shell script "/usr/bin/find " & theFolder & " -ipath *" & theName)

if (count (paragraphs of theFiles)) = 1 then

set theChoice to POSIX file (result)

my setContainer(theChoice)

else

set fileList to paragraphs of theFiles

set theChoice to POSIX file (choose from list fileList)

if theChoice is not {} then

my setContainer(theChoice)

end if

end if

on error

display dialog "Not Found" buttons {"OK"} default button 1 with icon caution

return

end try

on setContainer(aFile)

tell application "FileMaker Pro Advanced"

set cell "image" of current record to aFile

end tell

end setContainer

I get error message

FileMaker Pro Advanced got an error: AppleEvent timed out.

The frist question is that the file path leads to a file that contains other files that have all the pix. Therefore, there a way to say, 'start looking here and open all files'?

Incidenatlly, I am running OS 10.3.9

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