PDA

View Full Version : How to save the list as txt file?




chidambaram
Mar 10, 2009, 06:19 AM
Hi all,

I want to save the list of applications in my machine in a text file.

In terminal i did as "cd /Applications" and in next line "ls" . I received all the applications in my machine.

How can i save this list in text file using applescript.

Thanks in advance...



Tygernoot
Mar 10, 2009, 06:23 AM
I don't know about Applescript, but you can simply do this to save the list in a text file:

cd /Applications
ls > file.txt

If you specifically need Applescript I hope someone else can help you :)

pstoehr
Mar 10, 2009, 06:27 AM
Hi,
Hi all,

I want to save the list of applications in my machine in a text file.

In terminal i did as "cd /Applications" and in next line "ls" . I received all the applications in my machine.

How can i save this list in text file using applescript.

Thanks in advance...

instead of just "ls" do "ls > allPrgs.txt"

Best regards
Peter

chidambaram
Mar 10, 2009, 07:03 AM
thanks for all replies...

its working fine in terminal.

But i need in applescript...

steveca
Mar 10, 2009, 07:10 AM
not sure if i am understanding this right, but maybe i can help you...

Try to select all the applications and copy them. then open up textedit and paste and match style (do not paste as it wont work and will quit textedit). You will have a list of the applications you have copied...

hope it helps you

chidambaram
Mar 10, 2009, 07:15 AM
not sure if i am understanding this right, but maybe i can help you...

Try to select all the applications and copy them. then open up textedit and paste and match style (do not paste as it wont work and will quit textedit). You will have a list of the applications you have copied...

hope it helps you

I get the list of applications. I want to save that my code is

tell application "TextEdit"
activate
make new application
tell application "Terminal"
do script "cd /Applications"
do script "ls" in window 1
end tell
end tell


how can i save the result coming in ls command in text file?

Guiyon
Mar 10, 2009, 07:39 AM
What sort of information do you need? Using the below command may be a bit more thorough:
/usr/sbin/system_profiler SPApplicationsDataType

angelwatt
Mar 10, 2009, 07:46 AM
Here's simplified AppleScript. You don't need all those tell applications. It'll ask for a name of the file with a prompt, then use it in the output command. If it'll be a fixed name for the output you can skip the prompt and tie it in directly to the cmd. It's also currently set to save the file to your home directory.

display dialog "Enter name of file to be saved" default answer ""
set dialogInfo to result
set filename to text returned of dialogInfo
-- create command for script
set cmd to "ls /Applications/ > ~/" & filename
do shell script cmd