I only want to drag and drop a folder on this AppleScript
OK, that's possible. You need to wrap the entire script in an 'on open' handler so that it's called when items are dropped on the script:
on
open
theseItems
set
theItem
to
item 1
of
theseItems --
extract the first item
set
thePath
to
quoted form
of
POSIX path
of
theItem --
get its path
do shell script "chmod -R 770 " &
thePath
with
administrator privileges
do shell script "chown -R root:admin " &
thePath
with
administrator privileges
end
open
Note that this now needs to be saved as an application in order to be used as a droplet - you can't drop files/folders on a document.
The issues here are that 'on open' always passes a list of items, even if there's only one selected, so the first line extracts the first item from that list.
You might want to change that. For example, would you ever want to drop multiple items on the script and have them all change?
Other than that, the script is pretty much the same. Note that there are no checks here to ensure you drop a folder on the script - a file would work just as well. You'll have to decide whether that's a problem for you or not.