[Pythonmac-SIG] Findertools
Bill Bedford
billb@mousa.demon.co.uk
Tue, 19 Sep 2000 11:39:47 +0100
One of the interesting things about the finder appleevents is that
many will take a list of objects to work on. Using the finder in this
way is usually very much quicker than looping over a list in Python.
I have therefore modified my findertools with the following code:
def copy(src, dstdir):
"""Copy a file or a list of files to a folder"""
finder = _getfinder()
if type(src) == type([]):
src_fss = []
for s in range(len(src)):
src_fss.append(macfs.FSSpec(src[s]))
else:
src_fss = macfs.FSSpec(src)
dst_fss = macfs.FSSpec(dstdir)
return finder.duplicate(src_fss, to=dst_fss)
def move(src, dstdir):
"""Move a file or a list of files to a folder"""
finder = _getfinder()
if type(src) == type([]):
src_fss = []
for s in range(len(src)):
src_fss.append(macfs.FSSpec(src[s]))
else:
src_fss = macfs.FSSpec(src)
dst_fss = macfs.FSSpec(dstdir)
return finder.move(src_fss, to=dst_fss)
Jack, is there any chance of this being incorporated into future releases?
--
Bill Bedford
"Yes," said the skull. "Quit while you're a head, that's what I say."