Dealing with filename extensions - bash vs oascript
As your shell variable $file will always have a file extension in tact, you need to use the path property for Preview's document, which contains the full file path of the open file, including file extension:

cd somedir
for file in * ; do
  echo file name is $file

osascript&lt;&lt;EOF
  tell application "Preview"
    close (every document whose path ends with "$file")
  end tell
EOF
  sleep 1
done


This is slow, however, even without the sleep delay.  Another way you could do it is to enumerate the files in AppleScript instead:

osascript&lt;&lt;EOF
  use sys : application "System Events"
  use Preview : application "Preview"

  script
    property list : displayed name of every file ¬
                    in sys's folder "$somedir"
  end script

  repeat with f in result's list
    tell Preview's document named f to if exists ¬
    then close
  end repeat
EOF


This is almost instantaneous, and the displayed name property specifically uses the name as it's displayed in Finder, with or without its extension.  Therefore, it matches the name property of the Preview document.