Saturday, March 28, 2020

#1 2011-11-09 03:26:17 pm

jamespoc
Member
Registered: 2011-11-09
Posts: 2

applescript open action and quarantine items

Hi,

I have a simple applescript droplet, but not all dropped files are being passed to the open handler. It appears that the problem is with files that have the com.apple.quarantine attribute set. If I drop a single file with this attribute set, the droplet runs as expected. If I drop multiple files, the ones with the com.apple.quarantine attribute are silently exclude from the list. Here is a sample the exhibits the problem:

open theDropped
          display dialog "Dropped " & (theDropped's length) & " items"
end open

Say I drop five files on the droplet, and three of them have the quarantine attribute set, the droplet will pop a dialog saying "Dropped 2 items". If I drop one file WITH the quarantine attribute set it will say "Dropped 1 item". I have confirmed by looking at "theDropped" that it is the items with the quarantine attribute that are not making in on the list. If I first clear the quarantine attribute using xattr, everything works as expected.

How can I make the open handler see these "quarantined" files? I know I can preprocess the files to remove the attribute, but that just avoids the real problem.

Thanks!

Jim

Model: MacBook Pro
Browser: Safari 5.1.1 7535.51.22
Operating System: Mac OS X (10.7)


Filed under: applescript, quarantine

Offline

 

#2 2011-11-10 06:26:50 am

DevEd2
Member
From:: Maine, USA
Registered: 2011-09-20
Posts: 132

Re: applescript open action and quarantine items

The script doesn't work at all without a minor modification:

Applescript:

on open theDropped
   display dialog "Dropped " & (theDropped's length) & " items"
end open

Other than that, you can make the script call xattr every time something is dropped onto the droplet using the "do shell script" command:

Applescript:

on open theDropped
   do shell script "xattr " & theDropped
   display dialog "Dropped " & (theDropped's length) & " items"
end open

Hope this helps.


"There are two kinds of people in this world: those who are convinced there are two kinds of people in this world, and those who aren't." -Unknown

Offline

 

#3 2011-11-10 03:56:51 pm

jamespoc
Member
Registered: 2011-11-09
Posts: 2

Re: applescript open action and quarantine items

Thanks for the response. I don't see how this fixes the problem though. The variable theDropped should contain a list of all the files that were dropped onto the droplet. The problem is that dropped files that have the quarantine attribute set never make it onto the list for some reason (this only happens when multiple files are dropped onto the droplet). Since they never make it onto the list, the handler doesn't even know about them, and therefore, can't call xattr to change them. Am I missing something?

Thanks!

--Jim

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)