Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Open many images in Preview from Terminal' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Open many images in Preview from Terminal
Authored by: wmertens on May 19, '04 08:55:41AM
That is a nice script, but it's not hardened against spaces and giving subdirectories. Here's a new version with those two things fixed:

#!/bin/sh
# A simple bash script that uses Applescript to
# open multiple files in Preview. For example:
# "preview hello.png world.gif *.jpg"

if [ -z "$*" ]; then
  echo "Usage: $0 [FILE(S)]"
  exit
fi

PWD=${PWD//\//:}
for file in "$@";
do
  # Set all / to :
  file="${file//\//:}"
  if [ -n "$FILES" ]
  then
    FILES="$FILES, \"$PWD:$file\""
  else
    FILES="\"$PWD:$file\""
  fi
done;
osascript<<EOF
tell application "Preview"
  activate
  open {$FILES}
end tell
EOF


[ Reply to This | # ]