nollaf126
nollaf126

Reputation: 160

Using bash to navigate to a file in Finder

I drag a lot of graphic files from Finder directly into InDesign and Photoshop. I use a vey simple bash script to quickly open the directory containing the file.

cd "/Volumes/Server/Resources/stock1/"

open .

The script opens the correct directory, but I would like to know how to get it to also go to a specified file (e.g., image.eps) and highlight/select it. The directories I work with contain hundreds of files and have hard-to-look-through names. This would be a huge time-saver.

Thanks so much for any help. I'm using Mac OSX 10.9.5.

Upvotes: 3

Views: 1111

Answers (2)

chepner
chepner

Reputation: 531075

Use the -R (aka --reveal) option to select a single file:

open -R "/Volumes/Server/Resources/stock1/image.eps"

Something like,

open -R "/Volumes/Server/Resources/stock1/"*.eps

will not select all eps files in the folder, but instead will select each one successively, so that the end result is only the last file is selected.

Upvotes: 9

Penghe Geng
Penghe Geng

Reputation: 14601

@chepner's answer (-R option) is great if you want to highlight just one file. If you want to select multiple files, you may want to use Apple Script like this:

osascript -e 'tell application "Finder" to select files in folder "stock1" of folder "PHOTOS and IMAGES" of disk "Server" whose name ends with ".eps"'

Upvotes: 2

Related Questions