Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>reveal</code> command may be of assistance to you. It simply locates a file in the finder, opens a new window if necessary, and then selects the file—all that using just one line of code:</p> <pre><code>tell application "Finder" to reveal path:to:some:file </code></pre> <p>The file must actually exist for this to work, of course. You know a particular file/directory exists when it is presented in alias form (I.e. <code>Macintosh HD:Users:billybob:Desktop:howToHack.pdf</code>). Attempting to coerce a nonexistent file into an alias will result in an error. If you are 100% certain that the file exists and know exactly where it is, congratulations! You have one less thing to worry about. If your certainty level is anything less than 100%, use a <code>try-catch</code> block. They have saved my life on multiple occasions. That way, if you distribute your applications via the Internet like I do, your clients are not presented with undecipherable error messages.</p> <p>An example of this is demonstrated below:</p> <pre><code>set theFile to "/Users/billybob/Desktop/folder/subfolder/subfolder2/subfolder3/fineByMe.mp3" try set theFile to (theFile) as alias tell application "Finder" to reveal theFile on error display alert "The file " &amp; quoted form of theFile &amp; "does not exist." -- The variable 'theFile' couldn't be coerced into an alias. -- Therefore, 'theFile' still has a string value and it can be used in dialogs/alerts among other things. end try </code></pre> <p>Is this more efficient or less time consuming than what you've written? I'm not particularly sure, to be honest. However, I have written many scripts that have included the <code>reveal</code> command on Mac OS X 10.5.8 (Leopard), Mac OS X 10.6.8 (Snow-Leopard), and Mac OS X 10.7.3 (Lion), and the results have been satisfying.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload