tachyon Posted October 8, 2007 Posted October 8, 2007 I would like to get a list of all files (graphics files) on my hard drive that contain, as part of their filename, a product code from a field. I have a record with a "show Art" button attached to a script which I would like to produce a the list which might, for instance, appear in a finder window where I could simply double-click the one I need to edit and have it open in the relevant app. I have tried applescripting it and send event but haven't sussed it. Any clues? Thanks in advance. Roger
Ballycroy Posted October 31, 2007 Posted October 31, 2007 Change the name references as needed and put this under a Perform Applescript Script Step, attach to a button. Certain assumptions are made here: FilePath is a global text field with a reference to your local hard drive and a folder called "Images": HardDiskName:Images: theFile is the name of the image file. thefullPATH is a total reference to the image file, and because they are all PSD files I add the extension ".psd". Open with your favourite image editing software, in this case I am using Adobe Photoshop. tell application "FileMaker Pro Advanced" tell document "ImageDB" tell current record set thePATH to cell "FilePath" set theFile to cell "FileName" end tell end tell end tell set thefullPATH to thePATH & theFile & ".psd" as text as alias tell application "Adobe Photoshop CS" open thefullPATH end tell
tachyon Posted July 25, 2008 Author Posted July 25, 2008 Thanks for that however, it doesn't seem to include a search of the drive for file names that contain the product code i.e. my database has a field with a product code "E45" and my design filenames look like "E45 moulding", "E45 strap" etc. I would like to script a button that searches out and lists all the files containing E45 from whence I can select the one that needs changes made. There is no actual filepath for any image as part of the data base, only the product code. In an instance where I know the filepath I just use open url.
Ballycroy Posted July 28, 2008 Posted July 28, 2008 The Applescript Find command in OSX 10.4 seems to be broken. Here is a find example using Applescript and shell scripting: Note: If you are going to use it in your database, uncomment the first line and insert the correct field name and delete the second line. [color:red]--set theRESULT to cell "Your Cell Name" set theSEARCHitem to "E35" set theSCRIPT to "mdfind " & quoted form of theSEARCHitem set theTEXT to (do shell script theSCRIPT) set theCOUNT to count of paragraphs of the theTEXT if theTEXT is not "" then set theFILEALIAS to {} if theCOUNT = 1 then set theFILEALIAS to POSIX file theTEXT else if theCOUNT > 1 then repeat with i from 1 to theCOUNT set aFileREF to paragraph i of theTEXT set theFILEal to POSIX file aFileREF set end of theFILEALIAS to theFILEal end repeat end if set theFILE to choose from list theFILEALIAS end if try tell application "Finder" open theFILE end tell end try
comment Posted July 28, 2008 Posted July 28, 2008 The Applescript Find command in OSX 10.4 seems to be broken. AFAIK, there never was a "Find" command, so it's hardly broken. Try "Reveal" instead.
Ballycroy Posted July 28, 2008 Posted July 28, 2008 AFAIK, there never was a "Find" command, so it's hardly broken. Try "Reveal" instead. No, it's there. Your profile indicates OS: Mac OS X Panther. It was introduced in Mac OS X Tiger and uses the Spotlight search technology, but as I said not very well.
comment Posted July 29, 2008 Posted July 29, 2008 Yes, it is there, but not here: AppleScriptLanguageGuide Perhaps for a reason?
Ballycroy Posted July 29, 2008 Posted July 29, 2008 The Reveal command is not mentioned in the ApplescriptLanguageGuide. But is a command in the Finder dictionary (see attached).
comment Posted July 29, 2008 Posted July 29, 2008 You are right. There used to be (before OS X) a separate AppleScript Finder Guide, and that's where I took it from. Looks like now there's no Finder-specific reference, and all we have is the dictionary - so I guess it's proper to call it 'broken'.
tachyon Posted July 30, 2008 Author Posted July 30, 2008 Even if bits are broken or missing it still works and quite quickly on my machine - thanks, it has piqued my interest in applescripting. One other thing; how would you restrict the search to a specific folder or drive? What you have written digs up everything off every drive including stuff archived with time machine or stuff it - which is very clever but makes for a long list most of which is not current projects. Heading for applescript dictionary now, see if I can suss it.
Ballycroy Posted July 30, 2008 Posted July 30, 2008 (edited) Use the option -onlyin Example: The following script will search the folder you choose for the filename "E35". You may want to hardwire the actual path(s) in the script. [color:red]set theFolder to choose folder set theSearchFolder to quoted form of POSIX path of theFolder log theSearchFolder set theSEARCHitem to "E35" set theSCRIPT to "mdfind -onlyin " & theSearchFolder & " " & quoted form of theSEARCHitem set theTEXT to (do shell script theSCRIPT) If you click the Event Log when running the script, it will show what is happening. The AppleScriptLanguageGuide link that Comment provided is a good place to start learning Applescript. Also: http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptX/AppleScriptX.html Edited July 30, 2008 by Guest
Recommended Posts
This topic is 5958 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