Question Protected by Community
2 Rewriting the post to actually be a question and then posting the solution as an answer...
source | link

Make How can I make a password protected ZIP file via Automator Quick Action and Apple Scriptfrom a selection in the Finder app

Because I didn't find a solution, I'dwould like to share an apple script, putting different solutions together, for makinguse "Quick Actions" within the Finder app from a selection of files and/or folders to make a password protected ZIP file from a selection in the finder app by right clicking and selecting "Quick Actions":.

set display_text to "Please enter your password:"
repeat
    considering case
        set init_pass to text returned of (display dialog display_text default answer "" with hidden answer)
        set final_pass to text returned of (display dialog "Please verify your password below." buttons {"OK"} default button 1 default answer "" with hidden answer)
        if (final_pass = init_pass) then
            exit repeat
        else
            set display_text to "Mismatching passwords, please try again"
        end if
    end considering
end repeat

tell application "Finder"
    set theItems to selection
    set theItem to (item 1 of theItems) as alias
    set itemPath to quoted form of POSIX path of theItem
    set fileName to name of theItem
    set theFolder to POSIX path of (container of theItem as alias)
    set zipFile to quoted form of (fileName & ".zip")
    do shell script "cd '" & theFolder & "'; zip -x .DS_Store -r0 -P '" & final_pass & "' " & zipFile & " ./'" & fileName & "'"
end tell

Make a password protected ZIP file via Automator Quick Action and Apple Script

Because I didn't find a solution, I'd like to share an apple script, putting different solutions together, for making a password protected ZIP file from a selection in the finder app by right clicking and selecting "Quick Actions":

set display_text to "Please enter your password:"
repeat
    considering case
        set init_pass to text returned of (display dialog display_text default answer "" with hidden answer)
        set final_pass to text returned of (display dialog "Please verify your password below." buttons {"OK"} default button 1 default answer "" with hidden answer)
        if (final_pass = init_pass) then
            exit repeat
        else
            set display_text to "Mismatching passwords, please try again"
        end if
    end considering
end repeat

tell application "Finder"
    set theItems to selection
    set theItem to (item 1 of theItems) as alias
    set itemPath to quoted form of POSIX path of theItem
    set fileName to name of theItem
    set theFolder to POSIX path of (container of theItem as alias)
    set zipFile to quoted form of (fileName & ".zip")
    do shell script "cd '" & theFolder & "'; zip -x .DS_Store -r0 -P '" & final_pass & "' " & zipFile & " ./'" & fileName & "'"
end tell

How can I make a password protected ZIP file from a selection in the Finder app

I would like to use "Quick Actions" within the Finder app from a selection of files and/or folders to make a password protected ZIP file.

1
source | link

Make a password protected ZIP file via Automator Quick Action and Apple Script

Because I didn't find a solution, I'd like to share an apple script, putting different solutions together, for making a password protected ZIP file from a selection in the finder app by right clicking and selecting "Quick Actions":

set display_text to "Please enter your password:"
repeat
    considering case
        set init_pass to text returned of (display dialog display_text default answer "" with hidden answer)
        set final_pass to text returned of (display dialog "Please verify your password below." buttons {"OK"} default button 1 default answer "" with hidden answer)
        if (final_pass = init_pass) then
            exit repeat
        else
            set display_text to "Mismatching passwords, please try again"
        end if
    end considering
end repeat

tell application "Finder"
    set theItems to selection
    set theItem to (item 1 of theItems) as alias
    set itemPath to quoted form of POSIX path of theItem
    set fileName to name of theItem
    set theFolder to POSIX path of (container of theItem as alias)
    set zipFile to quoted form of (fileName & ".zip")
    do shell script "cd '" & theFolder & "'; zip -x .DS_Store -r0 -P '" & final_pass & "' " & zipFile & " ./'" & fileName & "'"
end tell