PDA

View Full Version : get info on a folder/app/etc.


octavius
03-12-2003, 10:40 AM
how do i do it? like when i right-click on an icon and select Get Info. just wondering how to do with terminal.

hayne
03-12-2003, 10:47 AM
I'm not sure what you are wanting to do. Are you asking how you can use a command in Terminal to bring up the GetInfo box on some file? Or are you asking what command to use in Terminal to get textual info (inside Terminal) on a file or folder?

If the latter, you need to look at the command 'ls'. For example:
ls -l
or
ls -l myfile

octavius
03-12-2003, 11:05 AM
simply open the GetInfo box. sorry that wasnt clear.

hayne
03-12-2003, 11:15 AM
I don't know how to bring up the GetInfo window using a command in Terminal. This is a capability of Finder. But maybe there is a way to use AppleScript to ask Finder to do it. You can run AppleScripts from Terminal via the use of /usr/bin/osascript

brmic
03-12-2003, 06:58 PM
this works:
osascript -e 'tell application "Finder" to open information window of folder "Documents" of folder "yourUsername" of folder "Users" of startup disk'

sorry about the awful syntax, never understood path handling in AppleScript. still might be a starting point

good luck
markus

hayne
03-12-2003, 10:09 PM
Here's a Bourne shell script that seems to work.
Copy and paste it into a new file and make it executable with 'chmod'


#!/bin/sh

# This script opens the Finder's "Get Info" window
# for the file or folder specified as a command-line argument.

scriptname=`basename $0`
if [ $# -lt 1 ]; then
echo "Usage: $scriptname file_or_folder"
exit
fi

path=$1

if [ ! -e $path ]; then
echo "$scriptname: $path: No such file or directory"
exit
fi

case $path in
/*) fullpath=$path ;;
~*) fullpath=$path ;;
*) fullpath=`pwd`/$path ;;
esac

if [ -d $fullpath ]; then
file_or_folder="folder"
else
file_or_folder="file"
fi

/usr/bin/osascript > /dev/null <<EOT
tell application "Finder"
set macpath to POSIX file "$fullpath" as text
open information window of $file_or_folder macpath
end tell
EOT

pmccann
03-13-2003, 01:02 AM
Nice script! There's a funky little companion script to this one at

http://forums.macosxhints.com/showthread.php?s=&threadid=6564&highlight=applescript+comments

Just allows you to set comments from the command line, but the implementation might be worth a gander if anyone's interested in this sort of thing. At this rate we'll have all Finder possibilities replaced by CLI equivalents by, say, 2038.

Cheers,
Paul