Ivan
Ivan

Reputation: 27

Cygwin: cygstart * Not Opening All Files

One thing that I really don't like with Cygwin is when I have to open files one by one. I set up an alias of opening files (instead of cygstart, I use open). However, everytime I want to open up multiple files, say a pdf, it will only open the first file in the directory. Here is what I type:

open *
open *.pdf
cygstart *
cygstart *.pdf

None of these work. However when I do something like mv * or cp * it works. Any help with this would be greatly appreciated! Thanks in advance.

Upvotes: 1

Views: 512

Answers (1)

szkj
szkj

Reputation: 743

* will expand to all files in the current directory.

For example:

$ ls
1.pdf  2.pdf  3.pdf

In this case * will expand to 1.pdf 2.pdf 3.pdf. If you give this as a parameter to an other command, then it will see 3 separate parameter. Many program can handle this, but apparently open and cygstart can handle only the first parameter.

To solve this problem this script should be added to a directory which is found in your PATH environment variable (e.g: c:\cygwin\bin):

myopen.sh:

for i in "$@"; do
  cygstart "$i"
done

After that it can be called like this:

myopen.sh *.pdf

Upvotes: 2

Related Questions