Jump to content

finding files


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

Recommended Posts

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

Link to comment
Share on other sites

  • 4 weeks later...

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

Link to comment
Share on other sites

  • 8 months later...

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Find_Command.jpg

Link to comment
Share on other sites

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'.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Guest
Link to comment
Share on other sites

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