tirtza Posted April 9, 2003 Share Posted April 9, 2003 I would like to search a directory to determine if a certain file exists there. How can I do this? Link to comment Share on other sites More sharing options...
jfmcel Posted April 10, 2003 Share Posted April 10, 2003 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 More sharing options...
tirtza Posted April 10, 2003 Author Share Posted April 10, 2003 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? Link to comment Share on other sites More sharing options...
Lee Smith Posted April 10, 2003 Share Posted April 10, 2003 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 More sharing options...
tirtza Posted April 10, 2003 Author Share Posted April 10, 2003 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. Link to comment Share on other sites More sharing options...
Lee Smith Posted April 10, 2003 Share Posted April 10, 2003 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 More sharing options...
tirtza Posted April 10, 2003 Author Share Posted April 10, 2003 so is there a way to script sherlock to get the path? Link to comment Share on other sites More sharing options...
tirtza Posted April 10, 2003 Author Share Posted April 10, 2003 I think there's a way to script the finder to get the path of a file. Does anyone know how? Link to comment Share on other sites More sharing options...
Lee Smith Posted April 10, 2003 Share Posted April 10, 2003 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 Link to comment Share on other sites More sharing options...
jfmcel Posted April 10, 2003 Share Posted April 10, 2003 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 More sharing options...
tirtza Posted April 10, 2003 Author Share Posted April 10, 2003 i tried that and got an error - the volumes are not indexed Link to comment Share on other sites More sharing options...
jfmcel Posted April 10, 2003 Share Posted April 10, 2003 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now