Shell: Find files and open them


set {astid, text item delimiters} to {text item delimiters, ".xls", ".ppt"}
set theseFiles to text items of (do shell script "/usr/bin/find ~ -name 'Template.xls' ;")
set text item delimiters to astid

set LIst_Of_Names to paragraphs of (theseFiles as string)
do shell script ("/usr/bin/open " & theseFiles)

What it does:
I have the script above that files a file called “Template.xls” 's path.
/Users/account/etc…/Template.xls

What I’m trying to do:
¢ find files named “Template.xls” & “Template.ppt”
¢ open both files usng do shell script

Any help would be appreciated.

hi sd,

when i use the open command and i already know the app i want to use i do it like this:


do shell script "/usr/bin/open -a \"/Applications/Microsoft Office X/Microsoft Excel\" /path/to/Template.xls"

you might use an if statement to open Template.ppt with PowerPoint vs Template.xls in Excel.

NOTE: i notice that my version of Excel does not have a ‘.app’ extension. if you use this for another application you may have to add ‘.app’.

thanks waltr,

The only problem is that when I distribute this script I don’t want to hardcode where the app might reside not to mention what version of office they might have. By just opening the file it’ll automatically open by the default application. Thanks for the suggestion though.

Hi slashdot,

If you’re trying to open Excel, you could use the creator type. Try this:

tell application "Finder"
	open (application file id "XCEL")
end tell

gl,

actually I’m trying to open 2 files the powerpoint and excel files named “Template.xls” & “Template.ppt”

thanks jacques greatly appreciated.

works perfectly.