How to list everything

Here is the challenge, I have to be able to obtain a list of the name of every item of all the mounted disk so I can use it to compare it’s content with another list. the script goes like this:

Tell application "Finder"
set theList to the count of every item of the entire contents of every disk
end tell

this script obviously returns a out of memory message (applescript has a resolution of 10 bit it seems since I can’t access more than 2048 items at once (whatever the type of items I’ve tried)).

I’m presently trying a combination of repeat statement and read/write/open for access command but it’s very difficult to debug and write since the script need to be able to run on any computer upon installation (all application are launched by their creator code, all folders path are obtained via the path to command and so on…)

Given that the system folder alone may contain thousands of files, it’s probably not possible to retrieve a list of names except folder by folder. The brief answer: recursively search each disk, then each folder, then each sub-folder while writing the contents of each folder to a text file. It’s simple enough applescript, but be prepared to wait all night for output.
Some OSAXEN, e.g., Jon’s Command may contain commands that will help (see ‘walk folders’).
Don’t shareware tools for listing the contents of disk exist? It’s be faster and easier.

"Here is the challenge, I have to be able to obtain a list of the name of every item of all the mounted disk so I can use it to compare it’s content with another list. "
My advice: don’t do this. In the system folder alone are thousands of items. Say you wish to compare two disks used by different users for six months. The number of differing files might number in the hundreds, and most wouldn’t be worth knowing, depending on how much the users tweaked their machines. (My the contents applescripts & quickeys folders change daily.)
Anyway, creating the file which lists every item on a hard drive should be simple; it’s a recursive search through every disk, folder, and subfolder until there are no more subfolders. At every folder, write the contents to a file (which will grow quite large). When done, close the file. Being applescript, this will take a very, very long time.
Comparing is another matter. The folder won’t be in the same order on another machine, so to compare, a search must be done. That’s assuming the users haven’t altered any folder names, created new folders and put old files in them…
I think there are shareware/freeware programs for listing the contents of a disk. Try version tracker.

your replies are greatly appreciated.
If the only thing I needed would be to list every item visible or not located on every drive I would actually, like most people suggested use tools like ANAT or something like it.
This is where I think you can help me since I’m pretty new to the applescript world. Is there a way to read the desktop file and compare it to another one, or any file?
anyway, I finally managed it, here is an example of it (the actual script is more complex because it includes try statements before every “set l1 to every…” line and if/then statements when there is an error because too much file or 0 files are found)

tell application "finder"
set l1 to every item of the entire contents of every disk whose name start with "a"
set l2 to every item of the entire contents of every disk whose name start with "b"
set l3 to every item of the entire contents of every disk whose name start with "c"
--go on like that to the end of the alphabet and include stuff like "&" "•" "-" " "
set alphaList to l1 & l2 & l3 & ...
set othersList to every item of the entire contents of every disk whose name is not in alphalist
set theList to alphaList & othersList
end tell

On a beige G3 300MHz computer with 12607 files spread more or less equally on four partitions of a 9 Gig drive, in 15 min, I had the complete list of the items in the computer, since this list will be done once for cataloging my dummy station (the list will be stored in a file), the amount of time saved when cleaning the station of every unwanted files is enormous because it’s much faster to compare the content of a drive to a list than to compare it to another drive on a network, plus you don’t loose bandwith.

I too have had similar problems with trying to do the same thing getting a list of every file including subfolders. Although my script looks something like this:

tell application "Finder"
get every file of entire contents of startup disk whose locked is false as list
end tell

When you run this script it will work for a long time only to give me a out of memory error.

I created a vanilla search script to find files on our file server which match certain criteria (name contains, date is older than…)
Fortunately for me, our server is divided into A-Z folders, with subfolders inside for each client. What I did to get around the memory limitation was to combine a pseudo-recursive search with the “entire contents” feature (break it down into smaller chunks before grabbing the entire contents). Depending on what you’re searching for, you can dig recursively for one, two, or three levels (slow), and then do an entire contents from there.
–this is from memory so forgive any mistakes:

property foundFiles : {}
tell app "Finder"
repeat with level1 in (folders in myDisk)
set end of foundFiles to (items in entire contents of level1)
--add a whose clause to filter this if possible
end repeat
end tell

That depends what kind of comparisons you want to make. You can be as broad as “date modified” or as specific as going byte by byte. If you want to actually compare resources contained in a desktop file, then I’m not sure how you could do that.

Instead, you can do this as a loop:

repeat with x from (32) to (255)
if (x) is not in {list of invalid ascii numbers (":", etc)}
set end of alphaList to every item of entire contents of every disk whose name starts with (ascii character x)
end if
end repeat

32 to 255 is probably not the right range, check your ascii map, but you get the idea.