title: Applescript to check if files exist
body: <p>I want to check if any of particular files (dictionaries) exist in "/Library/Dictionaries/". Here is my Applescript code lines:</p>
  
  <pre><code>tell application "Finder"
  try
      set theFolder to ("/Library/Dictionaries/")
      set fileNames to {"dict1.dictionary", "dict2.dictionary", "dict3.dictionary", "dict_n.dictionary"}
  on error
      set fileNames to false
  end try
  if fileNames is not false then
      try
          display dialog "You have already got the dictionary."
      end try
  end if
  end tell
  </code></pre>
  
  <p>Weirdly, the message <code>You have already got the dictionary.</code> is always shown albeit no listed files exist.</p>
  
  <p>My purpose is to check if any of the listed files exits, and if one or more of them exits then the message is to be displayed.</p>
  
  <p>In fact, this script will be run as a Unix bash script via <code>/usr/bin/osascript</code>, so I will be very grateful if you can help with either Apple script or Bash script.</p>