Emma in England Posted September 8, 2008 Posted September 8, 2008 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.
Søren Dyhr Posted September 8, 2008 Posted September 8, 2008 Read about "Document" in the Apple Events Reference found in the English Extras folder with your filemaker installation! --sd
Emma in England Posted September 8, 2008 Author Posted September 8, 2008 Thank you! I just spotted it while trawling for answers on line. Not an obvious answer but it works. Thanks!
Søren Dyhr Posted September 8, 2008 Posted September 8, 2008 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
Emma in England Posted September 9, 2008 Author Posted September 9, 2008 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?
bruceR Posted September 11, 2008 Posted September 11, 2008 (edited) 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 September 11, 2008 by Guest
Emma in England Posted September 11, 2008 Author Posted September 11, 2008 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!"
bruceR Posted September 11, 2008 Posted September 11, 2008 (edited) 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 September 11, 2008 by Guest
Emma in England Posted September 11, 2008 Author Posted September 11, 2008 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!
Recommended Posts
This topic is 5916 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 accountSign in
Already have an account? Sign in here.
Sign In Now