What's wrong? (9.1 - 9.2.2)

What’s wrong with this code? A friend of my reports that this script gives Error -1700 Finder got an error: Can’t make “Jack’s Hard Disk” into an item. He has a single drive on his desktop. I too tried with a single drive with the same disk name without any error. The only difference is I have 9.1 he has 9.2.2.

tell application "Finder"
	set TheDisks to (name of every disk of desktop) as list
	set FolderList to {}
	repeat with i from 1 to number of TheDisks
		set TheDisk to item i of TheDisks
		if (local volume of disk TheDisk) and (not ejectable of disk TheDisk) then
			set FolderList to list folder TheDisk
		end if
	end repeat
end tell

: What’s wrong with this code? A friend of my reports that this
: script gives Error -1700 Finder got an error: Can’t make
: “Jack’s Hard Disk” into an item.
: set FolderList to list folder TheDisk
set FolderList to list folder folder TheDisk
NG

: set FolderList to list folder folder TheDisk
: NG
Thanks, but this time the error changes to:
Error -1700 Finder got an error: Can’t make folder “Jack’s Hard Disk” into an item.
Should I change it to:
set FolderList to list folder folder (TheDisk as string)
This errors only comes in 9.2.2. Can anything wrong with the name “Jack’s Hard Disk” ?

: Thanks, but this time the error changes to: Error -1700 Finder
: got an error: Can’t make folder “Jack’s Hard Disk”
: into an item.

: Should I change it to: set FolderList to list folder folder
: (TheDisk as string)

: This errors only comes in 9.2.2. Can anything wrong with the name
: “Jack’s Hard Disk” ?

Hmmm. The script you posted doesn’t work on either of my machines. One of these is running Mac OS 8.6 (AppleScript 1.3.7), the other has Mac OS 9.2.1 (AS 1.6). The cure I posted - putting the word ‘folder’ (or the word ‘disk’) before the disk name - works on both machines. Other combinations that work within the Finder tell block are the rather long-winded:

set FolderList to list folder alias (disk TheDisk as string)
set FolderList to list folder (disk TheDisk as string)
set FolderList to list folder alias (TheDisk & ":")

If your script’s working on your own machine, it may mean that you have Jon’s Commands or Akua Sweets installed. These silently coerce path strings (which, strictly speaking, TheDisk isn’t - it’s just a name) to file specifications when the occasion demands. If that’s the reason it works for you, then it won’t work for your friend if he doesn’t have those OSAXen. Basically, ‘list folder’ requires a file specification, a Finder reference, an alias, or a path string. “Jack’s Hard Disk” is a perfectly good name, but it isn’t one of these four things. It’s just a name. A colon on the end would turn it into a path string for a volume.

That said, there are known to be several problems with AS 1.7, which comes with OS 9.2.2. There was an explanation on the MACSCRPT mailing list this morning (my time) from Chris Espinosa of Apple, concerning ‘list folder’. Apparently, the AS 1.7 version can’t accept path strings. The input has to be one of the other three types. This may have been fixed in AS 1.8.2b1. If not, it would be in the next Beta version.

I don’t know if you actually require the disk names for your purposes, but an easier way to get to what your excerpt does is:

 tell application "Finder"
    repeat with TheDisk in (disks where it is local volume and it is not ejectable)
      set FolderList to list folder TheDisk
    end repeat
  end tell

NG

: Hmmm. The script you posted doesn’t work on either of my
: machines. One of these is running Mac OS 8.6 (AppleScript
: 1.3.7), the other has Mac OS 9.2.1 (AS 1.6). The cure I posted
: - putting the word ‘folder’ (or the word ‘disk’) before the
: disk name - works on both machines. Other combinations that
: work within the Finder tell block are the rather long-winded:
: set FolderList to list folder alias (disk TheDisk as
: string)
: set FolderList to list folder (disk TheDisk as string)
: set FolderList to list folder alias (TheDisk & “:”)
: If your script’s working on your own machine, it may mean that
: you have Jon’s Commands or Akua Sweets installed. These
: silently coerce path strings (which, strictly speaking,
: TheDisk isn’t - it’s just a name) to file specifications when
: the occasion demands. If that’s the reason it works for you,
: then it won’t work for your friend if he doesn’t have those
: OSAXen. Basically, ‘list folder’ requires a file
: specification, a Finder reference, an alias, or a path string.
: “Jack’s Hard Disk” is a perfectly good name, but it
: isn’t one of these four things. It’s just a name. A colon on
: the end would turn it into a path string for a volume.
: That said, there are known to be several problems with AS 1.7,
: which comes with OS 9.2.2. There was an explanation on the
: MACSCRPT mailing list this morning (my time) from Chris
: Espinosa of Apple, concerning ‘list folder’. Apparently, the
: AS 1.7 version can’t accept path strings. The input has to be
: one of the other three types. This may have been fixed in AS
: 1.8.2b1. If not, it would be in the next Beta version.
: I don’t know if you actually require the disk names for your
: purposes, but an easier way to get to what your excerpt does
: is:
: tell application “Finder”
: repeat with TheDisk in (disks where it is local volume and it
: is not ejectable)
: set FolderList to list folder TheDisk
: end repeat
: end tell
: NG

Whether it was right or wrong, at last I decided to ask my friend to send me the AppleScript 1.7 extension and all the 1.7 osaxen to me via mail. I installed them into my external drive and tested my script with both AS 1.6 and AS 1.7. I am not exactly sure of the results because the Finder was in version 9.1 while I was testing the script with AS 1.7 extensions. As you mentioned earlier, most of the problems were with the “list folder” command of Standard Additions 1.7. I couldn’t understand how the old scripts would work with 1.7. I posted my findings below, if it helps others.

set FolderList to list folder alias (disk TheDisk as string) -- works both; on 1.6 and on 1.7
set FolderList to list folder (disk TheDisk as string) -- works on 1.6, does not work on 1.7
set FolderList to list folder alias (TheDisk & ":") -- works both; on 1.6 and on 1.7


set FolderItems to count of every item of entire contents of temporary items folder

I had to change the above line with the following to make it work with both 1.6 and 1.7

set FolderItems to count of every item of temporary items folder


set TheList to list folder temporary items folder

--I had to change the above line with the following to make it work with both 1.6 and 1.7

set TheList to name of every item of temporary items folder as list


set ThePath to SD & ":" & TI & ":" & TheFile
-- where, SD is the name of the startup disk and TI = "Temporary Items"
set FileInfo to info for ThePath -- didn't work with 1.7
set FileInfo to info for file ThePath -- did work with both 1.6 and 1.7

All the previous syntax works without any error with 1.6.
Again, thanks to everyone who replied my previous issues.