Re: Dealing with packages: files or folders?
Re: Dealing with packages: files or folders?
- Subject: Re: Dealing with packages: files or folders?
- From: Christopher Nebel <email@hidden>
- Date: Thu, 28 Jul 2005 16:40:13 -0700
On Jul 27, 2005, at 5:47 PM, Gregory J. Smith wrote:
So I want to get the contents of some packages and do things with
them. However my recursive code dies because, apparently,
applescript doesn't know what to do with the packages. Suggestions?
set main_folder to (choose folder)
set list_of_files to ProcessFolder(main_folder)
----------
-- recursive subroutineon ProcessFolder(the_folder)
set file_list to {}
tell application "Finder"
try
set file_list to (name of every file of the_folder)
on error -- there are no files of this type
-- do nothing
end try
set folder_list to (every folder of the_folder)
end tell
repeat with this_folder in folder_list
set file_list to file_list & ProcessFolder(this_folder)
end repeat
return file_list
end ProcessFolder
AppleScript isn't the issue here -- the Finder is. The Finder
attempts to make its scripting view match what you see in its GUI
(this is generally considered to be a good thing); therefore,
packages are not considered to be folders. However, they do still
have elements, just like folders do (though the dictionary lies on
this point), so you should be able to fix your script by saying "set
folder_list to (every folder of the_folder & every package of
the_folder)".
However, you should be very careful here. In general, doing a
recursive file tree scan ignoring the package-ness of items is a bad
idea -- packages have deliberately constructed contents, and mucking
with them the same as you would with any other folder that just
happens to be lying around is almost certainly wrong. Not that
dipping into packages is verboten by any means, but what you ought to
do is locate the packages first, and then process exactly those items.
--Chris Nebel
AppleScript and Automator Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden