Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Found Set in Applescript

Featured Replies

I am writing a Filemaker/Applescript solution to rename a huge number of files. Filemaker will calculate the new name, and Applescript calls a shell script to rename.

I want to be able to test on 2/3 records. The script insists on running on the whole database. I feel I should be able to say

tell found set

but I can't! Am I missing something? So many questions, but let's start with this one!

TIA.

Read about "Document" in the Apple Events Reference found in the English Extras folder with your filemaker installation!

--sd

  • Author

Thank you! I just spotted it while trawling for answers on line. Not an obvious answer but it works. Thanks!

Do you find applescript otherwise obvious, beyond this object? I would say it's a hit and miss to get any applescript written correct in first attempt, hence the need to write the scripts in a dedicated editor before embedding. We're not showered with meaning-full error messages here!

--sd

  • Author

Not obvious, but I've been doing it a while (more scripting QuarkXPress than Filemaker though).

I just made a scary discovery - addressing 'Document' rather than 'Database' has the required effect within Filemaker. But when I took the script back out to Script Editor to get (relatively) helpful error messages, it applied the script to the whole database. Eeek. Files were being renamed and luckily I realised in time and can restore from back up.

Is this right? And if so, how do I only address the found set from within Script Editor?

It really is most unhelpful to ask questions and make us play guessing games.

Post your script (or a simplified version) please.

In the same vein and level of detail as your question, I will state that I tried it in script editor and I do correctly get data only from the found set.

Edited by Guest

  • Author

Sorry to have caused offence! I thought the question was a fairly broad one of principle and the details of the script weren't relevant. Indeed they weren't, to the initial question. But here it is FWIW. Copying it has made me realise that the initial 'tell' still addresses the database, but I can't see that that should actually matter since all I'm doing is getting a number....

The database holds names and paths of images (19000). If it can extract a 6 digit sku code from the filename, it will rename the image with the result of a calculated field, otherwise it leaves it alone.

tell application "FileMaker Pro8.5"

tell database 1

set rec_count to count of records

end tell

end tell

repeat with i from 1 to rec_count

set do_it to "yes"

tell application "FileMaker Pro8.5"

tell document "MakroImages"

tell record i

if cell "SkuCode" ≠ "not valid sku" then

set source_file to cell "Source"

set dest_file to cell "Destination"

else

set do_it to "no"

end if

end tell

end tell

end tell

if do_it = "yes" then

set source_file to quoted form of source_file

set dest_file to quoted form of dest_file

do shell script "mv " & source_file & " " & dest_file

end if

end repeat

display dialog "Done!"

Sorry to have caused offence! I thought the question was a fairly broad one of principle and the details of the script weren't relevant. Indeed they weren't, to the initial question. But here it is FWIW. Copying it has made me realise that the initial 'tell' still addresses the database, but I can't see that that should actually matter since all I'm doing is getting a number....

Well, you're asking for the total number of records in the database, which is exactly what you said you DON'T want to do. So I can't see how the result is a surprise.

You need to be much more specific; you need to refer to the layout.

set rec_count to (count of records of layout "YourLayoutName" of database 1 of application "FileMaker Pro8.5")

However I'd suggest you do it like this:

tell application "FileMaker Pro 8.5"

tell document "MakroImages"

set rec_count to (count of records of layout "LayoutName")

repeat with i from 1 to rec_count

tell record i

if cell "SkuCode" ≠ "not valid sku" then

set source_file to cell "Source"

set dest_file to cell "Destination"

moveFile(source_file, dest_file)

end if

end tell

end repeat

end tell

display dialog "Done!"

end tell

on moveFile(source, target)

set source_file to quoted form of source

set dest_file to quoted form of target

do shell script "mv " & source_file & " " & dest_file

end moveFile

Edited by Guest

  • Author

Thanks Bruce, that's a much more rigorous and elegant approach! There is so much to contend with in this job - not least trying to organise back up of 230gb of data, and get all those file names into the database.... And assemble the non-nameable ones into contact sheets. I'm afraid as soon as my script worked, I rather abandoned it!

I'll implement your ideas, it will be much tidier and safer. Thanks!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.