Building a List Out of a Variable

I’m trying to write a short script that looks at a folder on my desktop and then analyzes the folders inside this main folder for archiving purposes. Folders colored blue are already archived and should be ignored, while folders with no label index colors should be counted and converted into a list by folder name. I cannot figure out how to convert my variable numWhiteFolders to a list. I am trying to build a list that I can eventually pass off to a shell command (such as rsync or ditto). Note: The display dialogs in this script were only for testing purposes and should be deleted or ignored for this question.

set theSource to (choose folder)
tell application "Finder" to set numWhiteFolders to count (every folder of folder theSource whose label index is 0)
if numWhiteFolders > 0 then
	display dialog of result
else
	display dialog "There are no jobs to archive."
end if

Can someone point me in the right direction? Thanks.

Model: MacBook
AppleScript: 2.0.1
Browser: Firefox 3.0.1
Operating System: Mac OS X (10.5)

This is happening because you are getting the count of the folders but not the folders themselves.
The folderList now contains a list of folders.


set theSource to (choose folder)
tell application "Finder" to set folderList to (every folder of folder theSource whose label index is 0)

set numWhiteFolders to (count of folderList)
if numWhiteFolders > 0 then
	display dialog numWhiteFolders
else
	display dialog "There are no jobs to archive."
end if

Cheers,

Craig

Thanks. It makes sense now. I see my mistake.

I’ve trimmed out my erroneous code from the first post. This trimmed snippet of code gives me the result that I was really after, which is the name of the folder whose label index was 0 (no label color):

set theSource to (choose folder)
tell application "Finder" to set folderList to (every folder of folder theSource whose label index is 0)

Model: MacBook
AppleScript: 2.0.1
Browser: Firefox 3.0.1
Operating System: Mac OS X (10.5)

it might work, but the syntax is not correct.
As theSource is an alias, omit the keyword folder, which is only needed, if the argument is a literal string


set theSource to (choose folder)
tell application "Finder" to set folderList to (every folder of theSource whose label index is 0)