Re: More files and subfolders
Re: More files and subfolders
- Subject: Re: More files and subfolders
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 14 May 2001 09:31:02 -0700
On 5/14/01 8:23 AM, "T.J. Mahaffey" <email@hidden> wrote:
>
Ok, thanks to Mr. Briggs, this script works on the files in the root of the
>
folder, but it still doesn't act on the files in the subfolders. I've pored
>
over the code and looked at other scripts acting on subfolders. As far as I
>
can tell, this script should work on files of subfolders. But it doesn't.
>
What am I doing wrong?
In the changeLabels handler, 'set theseFolderItems to every item in
theFolder' specifies by 'every item' just first level within. There IS a
Finder property 'entire contents' which is supposed to get everything to
every level, but it is notoriously buggy and unreliable (without letting you
know via an error) with large folders. So don't use it. You need to make the
handler recursive if it finds folders among its items. If you want to stick
with the Finder and not use 3rd-party osaxen, try the following. It will be
very slow with large folders.
on changeLabels(theFolder)
tell application "Finder"
activate
set theseFolderItems to every item in theFolder
repeat with thisItem in theseFolderItems
if kind of thisItem is not "Folder" then
set oldName to (name of thisItem)
set theOffset to (offset of "." in oldName)
set newName to (text 1 through (theOffset - 1)) of oldName
set name of thisItem to newName
else
my changeLabels(thisItem) -- recursive
end if
end repeat
end tell
end changeLabels
--
Paul Berkowitz