The manpage for open
in Sierra still says:
You can specify one or more file names (or pathnames), which are inter-
preted relative to the shell or Terminal window's current working direc-
tory. For example, the following command would open all Word files in the
current working directory:
open *.doc
Opened applications inherit environment variables just as if you had
launched the application directly through its full path. This behavior
was also present in Tiger.
That means your initial approach is usually also the correct one. That is "usually" as in: this open
command is buggy (and Preview is buggy, too).
If your PDFs have 'proper' filenames, then all is well and in a directory with 20 PDFs all PDFs will be opened in the manner the manpage promises.
However, if there are 'funny' filenames, legally allowed (or represented differently on the filesystem) on HFS+ but known for being 'difficult' in a shell environment, problems arise.
The globbing function for open is broken. If for example a filename starts with -
(minus sign) the next character gets interpreted as another option for the open
command. Since there are not many options available for the open
command this results often in an error. Spaces in filenames, everything that would need escaping in a normal shell command, seems to be troubling for this command.
Other bugs to observe are that using the option open -a Preview.app
does not work as might be expected. Further, it seems that Preview does not respect your preferences whether newly opened docs should all get their own window. Preview opens multiple PDFs with a simple open *.pdf
but all those docs are then 'hidden' in the sidebar of a single shared window. You then have to click the triangles to reveal that there are multiple files open now.
A number of files with clean names in a single working directory accessed via open *.pdf
with Preview.app set as your default PDF-viewer will open them all (well, I didn't check a probable upper limit on this…)
That leaves now the following options:
- either ensure you have clean filenames, then use your initial command as it confirms to Apple's documentation and is easier to remember, type and use
- avoid both Preview.app and the option
open -a Preview.app
- if both options above fail, only then use the solution from Allan's answer
open *.jpg