Re: Where is the Missing Link?.
Re: Where is the Missing Link?.
- Subject: Re: Where is the Missing Link?.
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 25 Sep 2001 08:20:12 -0700
On 9/25/01 7:32 AM, "Rachel Cogent" <email@hidden> wrote:
>
Last by 2 AM I finally became frustrated to tears at how to do this most
>
rudimentary operation in AppleScript Which 2 days ago I described in DOS
>
batch terms:
>
DIR/s>textfile
>
This command makes a directory list of all files and all files in all
>
subdirectories and writes the output to "textfile".
>
>
I must have wasted 16 hours in the last few days trying to do this
>
operation.
>
There must be a way to do this in simple AppleScript, please don't recommend
>
I buy Script debugger, I am on social security and have hardly any money.
>
Yesterday after reading the praises of AppleScript I was willing to forgive
>
and forget, but now I am as disgusted as ever. This is not even a request
>
for help, just an expression of my failure to understand the rules of this
>
most difficult of languages. Besides wanting to actually get something done,
>
I am struggling to learn this stuff and failing miserably.
>
Today I will download this ASLG, maybe that is the missing link.
>
Rachel,
I'm sorry you're having such trouble. Three of us, I believe, advised you
that the easiest way to do this was to use the Scripting Addition Akua
Sweets' 'the entries in' command, and two of us even spelled it out. The
ASSLG won't have anything about that.
That part was to get the names of every file in a folder, but not to write
it to a text file. To write to a text file, you need the read/write commands
from Standard Additions. The commands for Standard Additions are not, for
some reason, in the ASLG, but in a separate "Standard Additions" Guide
available where you got the ASLG. They are a little out-of-date, but not too
bad. I think you would probably find the $30. which the O'Reilly book
"AppleScript in a Nutshell" costs worth the expense, or maybe you can get
your public library, or a university library, to order it. It is actually
written specifically for people who are familiar with other programming
languages and does a fair amount of "translation" of concepts and terms for
people like you.
I don't know DOS, nor its DIR/s>textfile (that does like nice and simple),
but this should do what you want, once you get Akua Sweets and install it in
your Scripting Additions folder in System folder and restart computer. You
can get Akua Sweets free via <
http://www.osaxen.com>. Sometimes there are
problems with Akua's server. You can get it from my mac.com website:
<
http://homepage.mac.com/berkowit28/> Scripting Additions directory.
This should do what you want. assuming that your folder is:
set theFolder to alias "Your HD:Some Folder:Special Folder:" -- or
--set theFolder to alias "Your HD:Desktop Folder:Special Folder:"
set theFiles to the the entries in theFolder whose kinds are file as
alias to a depth of -1
set r to return -- start with a CR
repeat with i from 1 to (count theFiles)
set thePath to (item i of theFiles) as string -- just the file path
set r to r & return & thePath -- add the file path as a new line
end repeat
set r to to r & return -- add a CR to the end
set f to open for access "Your HD:Another Folder:File Name" with write
permission -- existing or new
write r to f starting at eof -- will continue from previous end of file
if not new file
close access f
There are ways to leave out a line or two by writing the list as a list, but
there were bugs with some versions of Standard Additions, I think, so I've
kept it simple. You need the repeat loop anyway to get the alias form into
string form for each file, since some of them will be in interior folders
and you can't just tack the file names onto the outer folder's path. (Using
the 'as string' parameter with 'the entries in' gets you just the file
names, not the whole path, whereas as alias' gets you the whole thing. If
you didn't have interior folders this script could be squeezed down to about
three lines with no repeat loop).
I hope this helps.
--
Paul Berkowitz