I have a script than closes open windows, but it only works when I have enabled the Finder "show all filename extensions" preference. Is there a robust way to accomplish this regardless of the state of the filename extension preference? I suppose I could try to close the file both with and without the extension, but that's an ugly solution
for file in * ; do
echo file name is $file
tell application "Preview"
close (every window whose name is "$file")