2 Newbie Questions

Hi,

Sorry in advance for these dumb questions :slight_smile:

  1. I want to set the file type and creator for 4 files to certain values. So I wrote this handler:

on set_file_type_and_creator(thefile, thetype, thecreator)
tell application ā€œFinderā€
set file type of file thefile to thetype
set creator type of file thefile to thecreator
end tell
end set_file_type_and_creator

which I invoke like this:

set_file_type_and_creator(file1, file_type, file_creator)
set_file_type_and_creator(file2, file_type, file_creator)
set_file_type_and_creator(file3, file_type, file_creator)
set_file_type_and_creator(file4, file_type, file_creator)

and it works just fine. But then I thought Iā€™d get clever, and write a handler that would process a list. That way, it would be more flexible and Iā€™d only have to call it once. So I changed it to this:

on set_file_type_and_creator_list(thefilelist, thetype, thecreator)
repeat with thefile in thefilelist
tell application ā€œFinderā€
set file type of file thefile to thetype
set creator type of file thefile to thecreator
end tell
end repeat
end set_file_type_and_creator_list

which I invoke like this:

set_file_type_and_creator({file1, file2, file3, file4}, file_type, file_creator)

Unfortunately, this gives me ā€œFinder got an error. A descriptor type mismatch occurred. (-10001)ā€. What do I need to change to make this work?

  1. Later, I need to delete these same 4 temporary files. So I do this:

tell application ā€œFinderā€
delete {file file1, file file2, file file3, file file4}
end tell

This works just fine, but each time a file is deleted, I hear an annoying ā€œclickā€ from the Finder. Is there any way to suppress that sound?

Thanks in advance!

When you invoke your revised subroutine like thisā€¦

set_file_type_and_creator({file1, file2, file3, file4}, file_type, file_creator)

ā€¦ what exactly does the file list contain in your first parameter, when it is invoked? Your example is just dummied up, but I suspect that youā€™re not passing the correct type of file reference to the subroutine.

So, reply back and paste in an example list like the one youā€™re passing as ā€˜thefilelistā€™.