Recursion fun

I decide to try to write the script in this thread recursively, but I am getting errors in the recursive calls. Can anyone help out?

Also: Would this work on 9?

EDIT: The problem actually lies in folders that have only one file. That file does not come back in a list, and thus can’t be coerced into an alias list… Hmmm…


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

This is a known bug. Try changing:

set files_ to files of folder_ as alias list
set folders_ to folders of folder_ as alias list

to

set files_ to (get files of folder_)
set folders_ to (ge folders of folder_)

Jon

Still doesn’t seem to work :frowning:

How does this do?


try
	set files_ to every file of folder_ as alias list
on error
	try
		set files_ to file 1 of folder as alias as list
	on error
		set files_ to {} --> check later to see if there were any files
	end
end

On my machine, sublist is a reserved word (some conflict with a scripting addition) so I’ve changed that. I’ve also tried not to use the “info for” command since you’re using the Finder for this mostly except that for some package files, the Finder balks at returning the size. I also don’t like the idea of having a file open while processing lots of files and then writing to it, I prefer to open, write, close. It’s also a bit faster to append to the end of lists instead of creating long strings and you can be a bit smarter if there aren’t actually subfolders. So, with all of that, this works for me:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Jon – Thanks, that runs a bit quicker. I’ve also added an if statement for extra tabs to space it out more neatly when there are very big files, or short dates:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

Now that that works, I want to know if it’ll run on 9…