April 9, 200322 yr I would like to search a directory to determine if a certain file exists there. How can I do this?
April 10, 200322 yr 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.]
April 10, 200322 yr 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?
April 10, 200322 yr 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
April 10, 200322 yr 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.
April 10, 200322 yr 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
April 10, 200322 yr Author I think there's a way to script the finder to get the path of a file. Does anyone know how?
April 10, 200322 yr 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
April 10, 200322 yr 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.
April 10, 200322 yr 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