2 Replies Latest reply on Jan 28, 2011 6:20 AM by GarethForwood

    Deleting External Files - Filename in Container Field



      Deleting External Files - Filename in Container Field


      Hi All,

      I have a photo database that I have set up in FM Pro, with container fields displaying the Jpeg Images.  Filemaker doesn't display the original of any image, but instead shows either a 200px wide image in List View and a 1200px image in the Forms.  There are several images now that I do not want to keep - I therefore need to delete the record, the 200px and 1200px images and the original image.  The filepaths for the 200px and 1200px images are stored in containers within the database. 

      Now, there is another complication - at some stage I started taking my photos in Canon's RAW format, with the file extension .CR2.  This means that some of the original images have the .jpg extension, and some .CR2.

      Is there any way that I can write a script that will simultaneously delete all the files (preferably send the files to the Trash in case I make a mistake) and the record, and that will not be affected by the variation in the file extensions for the original files?

      I have heard that Applescripts are needed for this sort of thing but I have never used them before - is there any guide (either from FM or externally) that provides a good intro to using Applescripts with FM Pro?

      Thanks in advance,

        • 1. Re: Deleting External Files - Filename in Container Field

          You can extract the file path from a container field with:

          GetValue ( containerField ; 2 )

          Thus you could write this script to delete one picture using data from one container field:

          Set Variable [$FilePath ; Value: GetValue ( YourTable::YourContainerField ; 2 ) ]
          Export Field Contents [$FilePath]

          A looping script could delete all the records for a found set of recors or all the records in your database.

          It won't, I don't think so anyway, move them to the trashcan. You might want to use Export Field contents to first export the picture to a folder on your desk top before using the above Export Field Contents [$FilePath] step to delete the original. Then you can review the contents of this folder before dragging it to the trash and deleting all your image files permanently.

          There are also file plug ins you can acquire and use to get more specific control over files than you can with just Filemaker.

          • 2. Re: Deleting External Files - Filename in Container Field

            Hi Phil,

            That sounds perfect, I'll give it a go.  Where they go isn't an issue, if it goes to a temp folder on the desktop that I then delete the files from, that also works to my liking (I hadn't actually considered that option)

            Thanks for the help.