Jump to content

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

Recommended Posts

Posted

i have two fields

field 1 = image ( this is a container that holds a jpg )

field 2 = imagename ( this is a field that holders the name of the image )

when i insert an image into field 1 i would like it to automatically add the file name into field 2.

is this possible?

i tried to mess around with Get(fileName) - but i am super new with FMP

thanks

mix

Posted

Use the File:Import Records:Folder... command. This will allow you to specify filenames, etc. when importing images, movies or other media files.

Posted

that doesn't work for me because i already have the records in the database. that would be great if i was starting the database from scratch. I want to be able to go through the database that i have set up and drop the images in and then get the file name to go into another field. Exactly what i said in my first post. Does anyone know how to do this. I am sure there is an easy way.

thanks,

mix

Posted

i guess not many people visit this forum.

please i need help. seems like a simple problem.

is there a more popular forum for fmp?

Posted

I don't know if there's a way to do it quickly but you could try to work around by writing a script to export the field content to a dir, then import it in again w/.

Posted

You do not say what platform you're on. On a Mac you can use AppleScript to get this info, if the image was inserted as a reference only. On a PC I believe the ImageScan plug-in can get do it.

If it is embedded, not as a reference, I don't believe there is any way to get the "name," because it no longer has a file name. It's just a picture in a container field; like a picture on the clipboard, the picture's there, but it has no name.

If you're on a Mac, look at this thread:

http://www.fmforums.com/threads/showflat.php/Cat/0/Number/105161/Main/105161

Posted

In FM7, AppleScript isn't required, if the file is a reference:

GetAsText(container)

will provide all info about it. This could be helpful if you're using Windows, as their AppleScript support sucks. wink.gif

Posted

ok i used GetAsText(container)

that works but it gives me this......

"

size:75,75

image:client_images/quick.jpg

imagemac:/Macintosh HD/Users/me/Desktop/client_images/quick.jpg

"

this is really cool but all i want is the name quick.jpg

is there a way to do it without using apple script.

I am on osx // but it seems like something that could be solved in fmp7

thank you all for responding // I am evaluating the

trial version of fmp7 and this is something that will help

me decide if i want to use it.

Posted

If the container field is named "Image":

Right ( GetAsText(Image);

Length ( GetAsText(Image) ) -

Position ( GetAsText(Image) ; "/" ; 1 ;

PatternCount ( GetAsText(Image); "/" )

)

)

Posted

One more thing, I just noticed... the calculation:

Length(container)

returns:

- empty, if the container is empty

- 0, if its a reference

- the image's size (in bytes?) if its stored internally.

So that also provides an easy way to tell when asking for the filename isn't going to work, since they image is stored inside the database.

Posted

If you decide to go with a < 7 version, here is an applescript that will give you the file name and a few other bits of info. Of course, you'll need to adjust the field names...

tell application "FileMaker Pro"

try

set TheImage to cell "Container" of current record

on error errMes

set cell "File Path" of current record to errMes

end try

try

set cell "File Path" of current record to TheImage as text

on error

set cell "File Path" of current record to "Image not stored as a reference"

set cell "File Size" of current record to ""

set cell "File Type" of current record to ""

return

end try

end tell

set FileInfo to (info for TheImage)

set theSize to (size of FileInfo) / 1048.567

tell application "FileMaker Pro"

set cell "File Name" of current record to name of FileInfo

set cell "File Type" of current record to file type of FileInfo

if theSize > 1000 then

set cell "File Size" of current record to ((((round (theSize / 10)) / 100)) as string & " MB") as string

else

set cell "File Size" of current record to ((round (theSize)) & " K") as string

end if

end tell

Posted

i have been using RightWords( MiddleValues( GetAsText(image); 2; 1 ); 1 )

it seems that it is working sometimes yes - sometimes no.

sometimes if i import an image like "image08.jpg" all i get is "jpg".

other times it works correctly. i am not sure why this is happening.

any ideas?

Posted

Bother, the word break rule for "." - it is considered NOT to be a word break when between letters ("fm.com") or numbers (3.4), but it is when they're mixed.

Try this instead:


Let( imgName = RightWords( MiddleValues( GetAsText(con); 2; 1 ); 1 );

  If ( Position( imgName; "."; 1; 1 ); imgName;

       RightWords( MiddleValues( GetAsText(con); 2; 1 ); 2 )

  )

)

Posted

hey shadow,

that works great- thanks for taking the time to write that.

is there any resources out there

for learning how to write these scripts.

I am pretty good at actionscripting and php, so i think i could pick it up.

thanks again

-mix

Posted

Well, the FileMaker help is okay, and explains what all the functions do. I'm not really sure where I picked up my "how-to" knowledge anymore, since that was a while ago...

I think "Scriptology" is supposed to be pretty good, but I would wait until the FM7 version is released to buy it. Perhaps others might have some better ideas.

  • 2 weeks later...
Posted

Not if the file name contains a space or other word separator. I suggest:

RightValues(Substitute(MiddleValues(GetAsText(container); 2; 1); "/"; "[par]"); 1)

"[par]" should be the paragraph caracter par.gif. I guess it doesn't work within quotes (which seems silly because that's the only place it should be)

Posted

if u stick into a "quote"it will work smile.gif

RightValues(Substitute(MiddleValues(GetAsText(container); 2; 1); "/"; " par.gif"); 1)

Good Call on filenames and spaces....but for "reference security" I make my users imageName = unique,ItemID or something.

that way u have eg:

ImageName | ItemID

--------------------

ABC.jpg | ABC

vs.

my house.jpg | ABC

this iway I can also estimate the name of the image_file.jpg and compund it...warn users that they have not "Uploaded/added" the "right" image.

Anyhow, thanx for more input!

Take care

  • 1 month later...
Posted

This GetAsText function sounds really useful. Would it be possible to use GetAsText if the file that is put in the containerfield is not a picture but something else, let's say un unknown file type?

Posted

Yep. It will return the paths for any file inserted, if it's inserted as a reference (which kind of makes sense, 'cause it has to store the paths to know where it is). But not for totally embedded files.

  • 3 weeks later...
Posted

This is just what I needed, but it is cutting the file name short at an underscore character. Any advice on how to accomodate that?

Bother, the word break rule for "." - it is considered NOT to be a word break when between letters ("fm.com") or numbers (3.4), but it is when they're mixed.

Try this instead:


Let( imgName = RightWords( MiddleValues( GetAsText(con); 2; 1 ); 1 );

  If ( Position( imgName; "."; 1; 1 ); imgName;

       RightWords( MiddleValues( GetAsText(con); 2; 1 ); 2 )

  )

)

Posted

I would not use RightWords. Try this:

Let ( info = GetAsText(PictAsRef);

Right ( info; Length(info) - Position ( info ; "/" ; 1 ; PatternCount(info; "/") ))

)

Posted

I have a different but similar inquiry... I am running FMPro7 on XP. I have a database that we have the images. Instead of saving all the images (DOH!)I have ~ 1500 images embedded as images in container fields. Now I can copy and paste into like Fireworks or something no problem. I am trying to export all the images... export them both as text (eg. productimage01.jpg) and to have Filemaker save the corresponding image file and in a certain specified folder (eg. images/productimage01.jpg).

HELP PLEASE smile.gif

Posted

Fenton & Shadow-

I see this thing you made... I have a similar need. My Field name is Image Large...

So, please, forgive me... but is this what we do...

1) Define a new field called save... 'imagename'

2) Set 'imagename' field to CALCULATION

3) define the calculation as:

Right ( GetAsText(Image Large);

Length ( GetAsText(Image Large) ) -

Position ( GetAsText(Image Large) ; "/" ; 1 ;

PatternCount ( GetAsText(Image Large); "/" )

)

)

And then Close... add field to my layout... and let it do it's thing??? That is what I did.. and I just get a '?'

If the container field is named "Image":

Right ( GetAsText(Image);

Length ( GetAsText(Image) ) -

Position ( GetAsText(Image) ; "/" ; 1 ;

PatternCount ( GetAsText(Image); "/" )

)

)

Posted

The calculation only gets the "name" for an image which as been inserted "as a reference only." Such an image is still a file on the disk, hence has a name. A completed embedded image is just that, an image, no file on disk, hence no name, hence "?" is all you get.

Possibly Troi File plug-in can do this. I know ImageScan can:

http://www.powersolutions.it/en/insidescan.html

I haven't used it however, because on a Mac we can do with AppleScript (not that it's something you'd want to do often).

Posted

ah... so that stuff is MAC... ok... thanks... I'll give that Troi and ImageScan stuff a look...

I have FMP7 on a MAC too... would it simply work if I opened this XP file in there do you think? and if it were to... would I use that stuff as a calculation :

respects-

eric

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