Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

searching a directory


tirtza

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

Recommended Posts

Use the Finder's exist command. It works with file specifications

tell application "Finder"

if exists file thePath then

...

end if

end tell

or aliases...

tell application "Finder"

if exists theFileAlias then

...

end if

end tell

[Replace the "..." with whatever you need to do. Use "not" or "else" to do something when there is no file already there. There are a number of ways to do this, but this is the most straight forward.]

Link to comment
Share on other sites

IE is helpful for this, type:

///

in the address box and it will show your drive(s), click your way to the file and its path shown will appear in the address:

(note: if you click on it, it will open the file, so don't do that)

HTH

Lee

Link to comment
Share on other sites

I was answering this question

> what if I don't know the path but I know the file name? Can I use Sherlock to search for the file and return the path?

Using the IE method, you can find and copy the file path this way. You can only see the file path using Sherlock.

Lee

Link to comment
Share on other sites

You can always try to open an applications dictionary from script editor and experiment using the vocabulary. I just did that and came up with the following little script

display dialog "Enter file name" default answer "enter here"

set theString to text returned of result

tell application "Sherlock 2"

search for theString without display

end tell

It appears to search the entire path for the string.

Link to comment
Share on other sites

Network volumes are not indexed. But if you are not doing content searches, that shouldn't matter. The scripted searches seems to work differently then running a search within Sherlock. It appears you can specify the volumes to be searched.

search theVolumeAliasList for ...

Sorry but I don't think I am much help here. You might want to look around a www.macscripter.net

Link to comment
Share on other sites

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