Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

coo1man1

macrumors newbie
Original poster
Aug 25, 2009
1
0
Hi,
I rlly need help iwth this command...

i have:
Code:
do shell script "cd /Users/henry/stuff/"

But i do not know where that file would be on someone else's computer. Is there a command that can have then drag the file in a text field or put in where it is?

Thanks,
Henry:apple:
 
Hi,
I rlly need help iwth this command...

i have:
Code:
do shell script "cd /Users/henry/stuff/"

But i do not know where that file would be on someone else's computer. Is there a command that can have then drag the file in a text field or put in where it is?

You can use the choose folder command to bring up a file chooser dialog.
 
You can also do this with many/most/several do shell scripts:

Code:
set aRandomVar to do shell script "ls /Users/"

aRandomVar will give you the list of files in the directory from the script.

it doesn't always work or capture errors. For example, if you use:

Code:
set aRandomVar to do shell script "cd /Us"

Applescript posts an error, but you haven't trapped it so your script halts. A try block works, however:

Code:
try
	do shell script "cd /Us"
on error errMsg number errNum
	-- you can include code based on the error if you want.
end try

errMsg returns: "sh: line 0: cd: /Us: No such file or directory"

mt
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.