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.

searching a directory

Featured Replies

I would like to search a directory to determine if a certain file exists there. How can I do this?

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

  • Author

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?

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

  • Author

what? i'm trying to write an applescript which will give me the path name of a file. I don't want any user interaction.

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

  • Author

so is there a way to script sherlock to get the path?

  • Author

I think there's a way to script the finder to get the path of a file. Does anyone know how?

Not that I'm aware of.

You might ask this question on the AppleScript list.

here is a URL where I would start my search. (you might already be aware of it)

http://www.apple.com/applescript/resources/

HTH

Lee

smile.gif

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.

  • Author

i tried that and got an error - the volumes are not indexed

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

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.